summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2020-02-17 09:47:01 +0100
committerErlang/OTP <otp@erlang.org>2020-02-17 09:47:01 +0100
commit2b2d0507b5371982c212af332620ee9e086b5d40 (patch)
tree15819f55192a9ff7caf607e6f86cb7661e495177 /lib
parent4dd2da3710c30f539808c09fde0914cfb09c98a1 (diff)
parent0cf20086273a4d2e8c93ba6d5bd01af6d2a440da (diff)
downloaderlang-2b2d0507b5371982c212af332620ee9e086b5d40.tar.gz
Merge branch 'bjorn/compiler/ERL-1170/OTP-16466' into maint-22
* bjorn/compiler/ERL-1170/OTP-16466: Fix crash when compiling convoluted use of receive
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/sys_core_fold.erl6
-rw-r--r--lib/compiler/test/core_fold_SUITE.erl14
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index 4939a94a92..eb1f69269c 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -2791,7 +2791,11 @@ opt_simple_let_2(Let0, Vs0, Arg0, Body, PrevBody, Sub) ->
true ->
Let1 = Let0#c_let{vars=Vars0,arg=Arg1,body=Body},
post_opt_let(Let1, Sub)
- end
+ end;
+ {[],Arg,Body} ->
+ %% The argument for a sequence must be a single value (not
+ %% #c_values{}). Therefore, we must keep the let.
+ post_opt_let(#c_let{vars=[],arg=Arg,body=Body}, Sub)
end.
%% post_opt_let(Let, Sub)
diff --git a/lib/compiler/test/core_fold_SUITE.erl b/lib/compiler/test/core_fold_SUITE.erl
index adfebd5158..f3bf716037 100644
--- a/lib/compiler/test/core_fold_SUITE.erl
+++ b/lib/compiler/test/core_fold_SUITE.erl
@@ -28,7 +28,8 @@
mixed_matching_clauses/1,unnecessary_building/1,
no_no_file/1,configuration/1,supplies/1,
redundant_stack_frame/1,export_from_case/1,
- empty_values/1,cover_letrec_effect/1]).
+ empty_values/1,cover_letrec_effect/1,
+ receive_effect/1]).
-export([foo/0,foo/1,foo/2,foo/3]).
@@ -48,7 +49,8 @@ groups() ->
mixed_matching_clauses,unnecessary_building,
no_no_file,configuration,supplies,
redundant_stack_frame,export_from_case,
- empty_values,cover_letrec_effect]}].
+ empty_values,cover_letrec_effect,
+ receive_effect]}].
init_per_suite(Config) ->
@@ -641,4 +643,12 @@ cover_letrec_effect(_Config) ->
end,
ok.
+receive_effect(_Config) ->
+ self() ! whatever,
+ {} = do_receive_effect(),
+ ok.
+
+do_receive_effect() ->
+ {} = receive _ -> {} = {} end.
+
id(I) -> I.