aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-10-30 17:07:22 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 15:56:29 +0100
commit03588c989909b9bca00a3d685f7486d567a55e19 (patch)
treed1788f68e4957ade22a96ab922f23557c74cfc98
parentf3ea2236bc8d11dd09b7eaaec3f175361e4771d3 (diff)
downloadotp-03588c989909b9bca00a3d685f7486d567a55e19.tar.gz
otp-03588c989909b9bca00a3d685f7486d567a55e19.tar.bz2
otp-03588c989909b9bca00a3d685f7486d567a55e19.zip
compiler: Fix v3_core for map update syntax
Make map update expressions safe, i.e. (foo())#{ k1 := 1 }
-rw-r--r--lib/compiler/src/v3_core.erl12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index b33799275b..b5fb65ff08 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -493,11 +493,11 @@ expr({map,L,Es0}, St0) ->
{Es1,Eps,St1} = map_pair_list(Es0, St0),
A = lineno_anno(L, St1),
{#c_map{anno=A,es=Es1},Eps,St1};
-expr({map,L,{var,Vl,Map},Es0}, St0) ->
- {Es1,Eps,St1} = map_pair_list(Es0, St0),
- A = lineno_anno(L, St1),
- Av = lineno_anno(Vl, St1),
- {#c_map{anno=A,var=#c_var{anno=Av,name=Map},es=Es1},Eps,St1};
+expr({map,L,M0,Es0}, St0) ->
+ {M1,Mps,St1} = safe(M0, St0),
+ {Es1,Eps,St2} = map_pair_list(Es0, St1),
+ A = lineno_anno(L, St2),
+ {#c_map{anno=A,var=M1,es=Es1},Mps++Eps,St2};
expr({bin,L,Es0}, St0) ->
try expr_bin(Es0, lineno_anno(L, St0), St0) of
{_,_,_}=Res -> Res
@@ -1505,7 +1505,7 @@ pattern({cons,L,H,T}, St) ->
pattern({tuple,L,Ps}, St) ->
ann_c_tuple(lineno_anno(L, St), pattern_list(Ps, St));
pattern({map,L,Ps}, St) ->
- #c_map{anno=lineno_anno(L, St),es=sort(pattern_list(Ps, St))};
+ #c_map{anno=lineno_anno(L, St), es=sort(pattern_list(Ps, St))};
pattern({map_field_exact,L,K,V}, St) ->
%% FIXME: Better way to construct literals? or missing case
%% {Key,_,_} = expr(K, St),