aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-02-10 15:16:24 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-02-10 15:16:24 +0100
commit993642bd638f194c2cbb0e62ee706e8d6eb81fce (patch)
tree9a330707eb2dd75fc36c8f237cc59be8a3b44896 /lib
parentedb90b1c1e6dc290727a516f4a00e939479aff98 (diff)
parent67663e057a35dfee45bf802539738b8ef107bd32 (diff)
downloadotp-993642bd638f194c2cbb0e62ee706e8d6eb81fce.tar.gz
otp-993642bd638f194c2cbb0e62ee706e8d6eb81fce.tar.bz2
otp-993642bd638f194c2cbb0e62ee706e8d6eb81fce.zip
Merge branch 'egil/compiler/maps-fix-sys_core_fold'
* egil/compiler/maps-fix-sys_core_fold: compiler: Fix sys_core_fold let optimization compiler: Add debug listing after sys_core_fold
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/compile.erl1
-rw-r--r--lib/compiler/src/core_lib.erl4
-rw-r--r--lib/compiler/test/map_SUITE.erl11
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 0bb4de6f17..5588f1fbe5 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -623,6 +623,7 @@ core_passes() ->
[{core_old_inliner,fun test_old_inliner/1,fun core_old_inliner/1},
{iff,doldinline,{listing,"oldinline"}},
?pass(core_fold_module),
+ {iff,dcorefold,{listing,"corefold"}},
{core_inline_module,fun test_core_inliner/1,fun core_inline_module/1},
{iff,dinline,{listing,"inline"}},
{core_fold_after_inlining,fun test_core_inliner/1,fun core_fold_module_after_inlining/1},
diff --git a/lib/compiler/src/core_lib.erl b/lib/compiler/src/core_lib.erl
index f506901099..ed181e3baa 100644
--- a/lib/compiler/src/core_lib.erl
+++ b/lib/compiler/src/core_lib.erl
@@ -105,8 +105,8 @@ vu_expr(V, #c_cons{hd=H,tl=T}) ->
vu_expr(V, H) orelse vu_expr(V, T);
vu_expr(V, #c_tuple{es=Es}) ->
vu_expr_list(V, Es);
-vu_expr(V, #c_map{es=Es}) ->
- vu_expr_list(V, Es);
+vu_expr(V, #c_map{var=M,es=Es}) ->
+ vu_expr(V, M) orelse vu_expr_list(V, Es);
vu_expr(V, #c_map_pair{key=Key,val=Val}) ->
vu_expr_list(V, [Key,Val]);
vu_expr(V, #c_binary{segments=Ss}) ->
diff --git a/lib/compiler/test/map_SUITE.erl b/lib/compiler/test/map_SUITE.erl
index bd514c60d0..86f65c3ed6 100644
--- a/lib/compiler/test/map_SUITE.erl
+++ b/lib/compiler/test/map_SUITE.erl
@@ -179,6 +179,17 @@ t_update_map_expressions(Config) when is_list(Config) ->
#{ a :=42, b:=42, c:=42 } = (maps:from_list([{a,1},{b,2},{c,3}]))#{ a := 42, b := 42, c := 42 },
#{ "a" :=1, "b":=42, "c":=42 } = (maps:from_list([{"a",1},{"b",2}]))#{ "b" := 42, "c" => 42 },
+ %% Test need to be in a fun.
+ %% This tests that let expr optimisation in sys_core_fold
+ %% covers maps correctly.
+ F = fun() ->
+ M0 = id(#{ "a" => [1,2,3] }),
+ #{ "a" := _ } = M0,
+ M0#{ "a" := b }
+ end,
+
+ #{ "a" := b } = F(),
+
%% Error cases, FIXME: should be 'badmap'?
{'EXIT',{badarg,_}} = (catch (id(<<>>))#{ a := 42, b => 2 }),
{'EXIT',{badarg,_}} = (catch (id([]))#{ a := 42, b => 2 }),