aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_eval.erl
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-03-08 18:12:13 +0100
committerAnthony Ramine <[email protected]>2014-03-14 21:51:51 +0100
commit766b8d3877a9c304e61828af4f376c5c4fb70a8e (patch)
tree7077996e90b271b78fc6e0b40b9287dc7470ad55 /lib/stdlib/src/erl_eval.erl
parent870737ab657433c5e8751255fe3c4d298202d142 (diff)
downloadotp-766b8d3877a9c304e61828af4f376c5c4fb70a8e.tar.gz
otp-766b8d3877a9c304e61828af4f376c5c4fb70a8e.tar.bz2
otp-766b8d3877a9c304e61828af4f376c5c4fb70a8e.zip
Fix evaluation of empty map updates in erl_eval
Diffstat (limited to 'lib/stdlib/src/erl_eval.erl')
-rw-r--r--lib/stdlib/src/erl_eval.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/stdlib/src/erl_eval.erl b/lib/stdlib/src/erl_eval.erl
index 3a4108e297..3974fbc4ec 100644
--- a/lib/stdlib/src/erl_eval.erl
+++ b/lib/stdlib/src/erl_eval.erl
@@ -18,6 +18,9 @@
%%
-module(erl_eval).
+%% Guard is_map/1 is not yet supported in HiPE.
+-compile(no_native).
+
%% An evaluator for Erlang abstract syntax.
-export([exprs/2,exprs/3,exprs/4,expr/2,expr/3,expr/4,expr/5,
@@ -243,11 +246,18 @@ expr({record,_,_,Name,_}, _Bs, _Lf, _Ef, _RBs) ->
%% map
expr({map,_, Binding,Es}, Bs0, Lf, Ef, RBs) ->
{value, Map0, Bs1} = expr(Binding, Bs0, Lf, Ef, RBs),
- {Vs,Bs} = eval_map_fields(Es, Bs1, Lf, Ef),
- ret_expr(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), Bs, RBs);
+ case Map0 of
+ #{} ->
+ {Vs,Bs} = eval_map_fields(Es, Bs1, 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);
+ _ ->
+ erlang:raise(error, {badarg,Map0}, stacktrace())
+ end;
expr({map,_,Es}, Bs0, Lf, Ef, RBs) ->
{Vs,Bs} = eval_map_fields(Es, Bs0, Lf, Ef),
ret_expr(lists:foldl(fun