aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_core.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-09-17 16:50:05 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 15:56:25 +0100
commit08a9a9a7113d310de2e6511d898a06cb8a559ce8 (patch)
tree6260885fdc38c40273564ef8b006a9b6e12f2776 /lib/compiler/src/v3_core.erl
parent2a943f14a44903eb8e67549978de5dbf7275ad57 (diff)
downloadotp-08a9a9a7113d310de2e6511d898a06cb8a559ce8.tar.gz
otp-08a9a9a7113d310de2e6511d898a06cb8a559ce8.tar.bz2
otp-08a9a9a7113d310de2e6511d898a06cb8a559ce8.zip
compiler: Handle literals, not just atoms, as keys in maps
Diffstat (limited to 'lib/compiler/src/v3_core.erl')
-rw-r--r--lib/compiler/src/v3_core.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 1ef710a260..32b65333a4 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -1498,8 +1498,21 @@ pattern({tuple,L,Ps}, St) ->
pattern({map,L,Ps}, St) ->
#c_map{anno=lineno_anno(L, St),es=sort(pattern_list(Ps, St))};
pattern({map_field,L,K,V}, St) ->
+ %% FIXME: Better way to construct literals? or missing case
+ %% {Key,_,_} = expr(K, St),
+ Key = case K of
+ {bin,L,Es0} ->
+ case constant_bin(Es0) of
+ error ->
+ throw(badmatch);
+ Bin ->
+ #c_literal{anno=lineno_anno(L,St),val=Bin}
+ end;
+ _ ->
+ pattern(K,St)
+ end,
#c_map_pair{anno=lineno_anno(L, St),
- key=pattern(K, St),
+ key=Key,
val=pattern(V, St)};
pattern({bin,L,Ps}, St) ->
%% We don't create a #ibinary record here, since there is