diff options
author | Björn-Egil Dahlberg <[email protected]> | 2013-09-17 16:50:05 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-01-28 15:56:25 +0100 |
commit | 08a9a9a7113d310de2e6511d898a06cb8a559ce8 (patch) | |
tree | 6260885fdc38c40273564ef8b006a9b6e12f2776 /lib/compiler/src/v3_kernel.erl | |
parent | 2a943f14a44903eb8e67549978de5dbf7275ad57 (diff) | |
download | otp-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_kernel.erl')
-rw-r--r-- | lib/compiler/src/v3_kernel.erl | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl index 84b3a4e37f..3d2dbf2088 100644 --- a/lib/compiler/src/v3_kernel.erl +++ b/lib/compiler/src/v3_kernel.erl @@ -662,10 +662,10 @@ pattern(#c_tuple{anno=A,es=Ces}, Isub, Osub0, St0) -> pattern(#c_map{anno=A,es=Ces}, Isub, Osub0, St0) -> {Kes,Osub1,St1} = pattern_list(Ces, Isub, Osub0, St0), {#k_map{anno=A,es=Kes},Osub1,St1}; -pattern(#c_map_pair{anno=A,key=Kk0,val=Cv},Isub, Osub0, St0) -> - Kk = #k_atom{val=Kk0#c_literal.val}, - {Kv,Osub1,St1} = pattern(Cv, Isub, Osub0, St0), - {#k_map_pair{anno=A,key=Kk,val=Kv},Osub1,St1}; +pattern(#c_map_pair{anno=A,key=Ck,val=Cv},Isub, Osub0, St0) -> + {Kk,Osub1,St1} = pattern(Ck, Isub, Osub0, St0), + {Kv,Osub2,St2} = pattern(Cv, Isub, Osub1, St1), + {#k_map_pair{anno=A,key=Kk,val=Kv},Osub2,St2}; pattern(#c_binary{anno=A,segments=Cv}, Isub, Osub0, St0) -> {Kv,Osub1,St1} = pattern_bin(Cv, Isub, Osub0, St0), {#k_binary{anno=A,segs=Kv},Osub1,St1}; @@ -1270,12 +1270,9 @@ group_value(k_cons, Cs) -> [Cs]; %These are single valued group_value(k_nil, Cs) -> [Cs]; group_value(k_binary, Cs) -> [Cs]; group_value(k_bin_end, Cs) -> [Cs]; -group_value(k_bin_seg, Cs) -> - group_bin_seg(Cs); -group_value(k_bin_int, Cs) -> - [Cs]; -group_value(k_map, Cs) -> - group_map(Cs); +group_value(k_bin_seg, Cs) -> group_bin_seg(Cs); +group_value(k_bin_int, Cs) -> [Cs]; +group_value(k_map, Cs) -> group_map(Cs); group_value(_, Cs) -> %% group_value(Cs). Cd = foldl(fun (C, Gcs0) -> dict:append(clause_val(C), C, Gcs0) end, @@ -1467,7 +1464,7 @@ arg_val(Arg, C) -> end; #k_map{es=Es} -> Keys = [begin - #k_map_pair{key=#k_atom{val=Key}} = Pair, + #k_map_pair{key=#k_literal{val=Key}} = Pair, Key end || Pair <- Es], ordsets:from_list(Keys) |