diff options
author | Björn Gustavsson <[email protected]> | 2018-08-09 13:59:10 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-08-09 13:59:10 +0200 |
commit | 4dcc640791674ee7d28fb2e29a064175ceb46f2a (patch) | |
tree | 5cd25f8fbebaa82b6769d4e9db175accd96f5b0f /lib/compiler/test/core_SUITE_data/fun_letrec_effect.core | |
parent | ca9f2fe073b587e70b5502c87be3eca6f72ddd57 (diff) | |
parent | a2b94643d345505bcee103b114147e3cb962b8ac (diff) | |
download | otp-4dcc640791674ee7d28fb2e29a064175ceb46f2a.tar.gz otp-4dcc640791674ee7d28fb2e29a064175ceb46f2a.tar.bz2 otp-4dcc640791674ee7d28fb2e29a064175ceb46f2a.zip |
Merge pull request #1910 from bjorng/bjorn/compiler/letrec-side-effect-fix/ERL-658/OTP-15188
Fix side-effect optimization when compiling from Core Erlang
Diffstat (limited to 'lib/compiler/test/core_SUITE_data/fun_letrec_effect.core')
-rw-r--r-- | lib/compiler/test/core_SUITE_data/fun_letrec_effect.core | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/compiler/test/core_SUITE_data/fun_letrec_effect.core b/lib/compiler/test/core_SUITE_data/fun_letrec_effect.core new file mode 100644 index 0000000000..ab6f5b7940 --- /dev/null +++ b/lib/compiler/test/core_SUITE_data/fun_letrec_effect.core @@ -0,0 +1,25 @@ +module 'fun_letrec_effect' ['fun_letrec_effect'/0, 'ok'/0, 'wat'/0] +attributes [] + +'fun_letrec_effect'/0 = + fun () -> + do apply 'wat'/0() + receive + <'bar'> when 'true' -> 'ok' + <_0> when 'true' -> 'failed' + after 'infinity' -> + 'true' + +%% The return value (bar) of the fun was optimized away because the result of +%% the `letrec ... in` was unused, despite the fun's return value being +%% relevant for the side-effect of the expression. +'wat'/0 = + fun () -> + let <Self> = call 'erlang':'self'() in + do letrec 'f'/0 = fun () -> + do call 'maps':'put'('foo', 'bar', ~{}~) + 'bar' + in call 'erlang':'send'(Self, apply 'f'/0()) + 'undefined' + +end |