File 0708-Fix-crash-when-compiling-convoluted-use-of-receive.patch of Package erlang

From 0cf20086273a4d2e8c93ba6d5bd01af6d2a440da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 11 Feb 2020 14:41:02 +0100
Subject: [PATCH] Fix crash when compiling convoluted use of receive

https://bugs.erlang.org/browse/ERL-1170
---
 lib/compiler/src/sys_core_fold.erl    |  6 +++++-
 lib/compiler/test/core_fold_SUITE.erl | 14 ++++++++++++--
 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.
-- 
2.16.4

openSUSE Build Service is sponsored by