diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-04-02 18:35:53 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-04-03 14:32:44 +0200 |
commit | c655521ab142547c371df3470a3fc62beef048ae (patch) | |
tree | a65ac7a355a87f7e1787e93993f3c79c857d6734 | |
parent | cc7a3c5896bc266bb97287dd4e31b696d8cf604f (diff) | |
download | otp-c655521ab142547c371df3470a3fc62beef048ae.tar.gz otp-c655521ab142547c371df3470a3fc62beef048ae.tar.bz2 otp-c655521ab142547c371df3470a3fc62beef048ae.zip |
compiler: Fix compiling map keys in patterns from core
-rw-r--r-- | lib/compiler/src/core_pp.erl | 6 | ||||
-rw-r--r-- | lib/compiler/src/sys_core_fold.erl | 12 |
2 files changed, 7 insertions, 11 deletions
diff --git a/lib/compiler/src/core_pp.erl b/lib/compiler/src/core_pp.erl index a76327457d..83412ecdd7 100644 --- a/lib/compiler/src/core_pp.erl +++ b/lib/compiler/src/core_pp.erl @@ -120,7 +120,11 @@ format_1(#c_literal{anno=A,val=Bitstring}, Ctxt) when is_bitstring(Bitstring) -> format_1(#c_binary{anno=A,segments=Segs}, Ctxt); format_1(#c_literal{anno=A,val=M},Ctxt) when is_map(M) -> Pairs = maps:to_list(M), - Cpairs = [#c_map_pair{op=#c_literal{val=assoc}, + Op = case Ctxt of + #ctxt{ class = clause } -> exact; + _ -> assoc + end, + Cpairs = [#c_map_pair{op=#c_literal{val=Op}, key=#c_literal{val=V}, val=#c_literal{val=K}} || {K,V} <- Pairs], format_1(#c_map{anno=A,arg=#c_literal{val=#{}},es=Cpairs},Ctxt); diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index b7422318b2..ce40213bad 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -1556,16 +1556,8 @@ map_pair_pattern_list(Ps0, Isub, Osub0) -> {Ps,Osub}. map_pair_pattern(#c_map_pair{op=#c_literal{val=exact},key=K0,val=V0}=Pair,{Isub,Osub0}) -> - {K,Osub1} = case cerl:type(K0) of - binary -> - K1 = eval_binary(K0), - case cerl:type(K1) of - literal -> {K1,Osub0}; - _ -> pattern(K0,Isub,Osub0) - end; - _ -> pattern(K0,Isub,Osub0) - end, - {V,Osub} = pattern(V0,Isub,Osub1), + K = expr(K0, Isub), + {V,Osub} = pattern(V0,Isub,Osub0), {Pair#c_map_pair{key=K,val=V},{Isub,Osub}}. bin_pattern_list(Ps0, Isub, Osub0) -> |