diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-05-12 16:36:59 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-05-12 16:36:59 +0200 |
commit | c563f5866b42a3479050241284fffc1245aebe7d (patch) | |
tree | 8289c9cd9fb5ec561a8eea25ed56f26a87234d61 /lib/stdlib | |
parent | 441c5a4dbc01e33db11b9497c14927da1af896f6 (diff) | |
parent | ec15a2aaab58816c728676807c0b6e61d5a5185e (diff) | |
download | otp-c563f5866b42a3479050241284fffc1245aebe7d.tar.gz otp-c563f5866b42a3479050241284fffc1245aebe7d.tar.bz2 otp-c563f5866b42a3479050241284fffc1245aebe7d.zip |
Merge branch 'nox/fix-eval-map-update/OTP-11922' into maint
* nox/fix-eval-map-update/OTP-11922:
Fix evaluation of map updates in the debugger and erl_eval
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/erl_eval.erl | 8 | ||||
-rw-r--r-- | lib/stdlib/test/erl_eval_SUITE.erl | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/stdlib/src/erl_eval.erl b/lib/stdlib/src/erl_eval.erl index acde3ad5d6..3cfedfee97 100644 --- a/lib/stdlib/src/erl_eval.erl +++ b/lib/stdlib/src/erl_eval.erl @@ -244,17 +244,17 @@ expr({record,_,_,Name,_}, _Bs, _Lf, _Ef, _RBs) -> erlang:raise(error, {undef_record,Name}, stacktrace()); %% map -expr({map,_, Binding,Es}, Bs0, Lf, Ef, RBs) -> - {value, Map0, Bs1} = expr(Binding, Bs0, Lf, Ef, RBs), +expr({map,_,Binding,Es}, Bs0, Lf, Ef, RBs) -> + {value, Map0, Bs1} = expr(Binding, Bs0, Lf, Ef, none), case Map0 of #{} -> - {Vs,Bs} = eval_map_fields(Es, Bs1, Lf, Ef), + {Vs,Bs2} = eval_map_fields(Es, Bs0, Lf, Ef), Map1 = lists:foldl(fun ({map_assoc,K,V}, Mi) -> maps:put(K, V, Mi); ({map_exact,K,V}, Mi) -> maps:update(K, V, Mi) end, Map0, Vs), - ret_expr(Map1, Bs, RBs); + ret_expr(Map1, merge_bindings(Bs2, Bs1), RBs); _ -> erlang:raise(error, {badarg,Map0}, stacktrace()) end; diff --git a/lib/stdlib/test/erl_eval_SUITE.erl b/lib/stdlib/test/erl_eval_SUITE.erl index b91d14b5b8..b55324161b 100644 --- a/lib/stdlib/test/erl_eval_SUITE.erl +++ b/lib/stdlib/test/erl_eval_SUITE.erl @@ -1451,6 +1451,13 @@ eep43(Config) when is_list(Config) -> " {Map#{a := B},Map#{a => c},Map#{d => e}} " "end.", {#{a => b},#{a => c},#{a => b,d => e}}), + check(fun () -> + lists:map(fun (X) -> X#{price := 0} end, + [#{hello => 0, price => nil}]) + end, + "lists:map(fun (X) -> X#{price := 0} end, + [#{hello => 0, price => nil}]).", + [#{hello => 0, price => 0}]), error_check("[camembert]#{}.", {badarg,[camembert]}), error_check("#{} = 1.", {badmatch,1}), ok. |