LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0284-sys_core_fold-Eliminate-crash-for-map-update-in-guar.patch of Package erlang (Project home:Ledest:erlang:20)

From 6703828ea9085a4125812cfa47631d061032c514 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Wed, 25 Apr 2018 07:41:49 +0200
Subject: [PATCH 1/2] sys_core_fold: Eliminate crash for map update in guard

sys_core_fold would crash when attempting to optimize this code:

    t() when (#{})#{}->
        c.
---
 lib/compiler/src/sys_core_fold.erl    |  2 ++
 lib/compiler/test/core_fold_SUITE.erl | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index bb3a9c7628..167383a202 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -214,6 +214,8 @@ opt_guard_try(#c_case{clauses=Cs}=Term) ->
     Term#c_case{clauses=opt_guard_try_list(Cs)};
 opt_guard_try(#c_clause{body=B0}=Term) ->
     Term#c_clause{body=opt_guard_try(B0)};
+opt_guard_try(#c_let{vars=[],arg=#c_values{es=[]},body=B}) ->
+    B;
 opt_guard_try(#c_let{arg=Arg,body=B0}=Term) ->
     case opt_guard_try(B0) of
 	#c_literal{}=B ->
-- 
2.16.3