diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-08-18 18:45:26 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-08-26 12:12:48 +0200 |
commit | 4e84810eca640220a333f104d25412399b6c0d31 (patch) | |
tree | 0dd1d65317dc7afca245ded38cd5293f0d285b65 | |
parent | 9870cec36b633c3787007e3acd6cebb03fa8545b (diff) | |
download | otp-4e84810eca640220a333f104d25412399b6c0d31.tar.gz otp-4e84810eca640220a333f104d25412399b6c0d31.tar.bz2 otp-4e84810eca640220a333f104d25412399b6c0d31.zip |
compiler: Reintroduce binary limit for Map keys
-rw-r--r-- | lib/compiler/src/v3_core.erl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index 9f1f3b635c..348ef9051d 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -1609,7 +1609,8 @@ pattern_map_pairs(Ps, St) -> %% remove cluddering annotations pattern_map_clean_key(#c_literal{val=V}) -> {literal,V}; -pattern_map_clean_key(#c_var{name=V}) -> {var,V}. +pattern_map_clean_key(#c_var{name=V}) -> {var,V}; +pattern_map_clean_key(_) -> erlang:throw(nomatch). pattern_alias_map_pairs([],_,_,_) -> []; pattern_alias_map_pairs([#c_map_pair{key=Ck}=Pair|Pairs],Kdb,Kset,St) -> @@ -1630,11 +1631,17 @@ pattern_alias_map_pair_patterns([Cv1,Cv2|Cvs]) -> pattern_alias_map_pair_patterns([pat_alias(Cv1,Cv2)|Cvs]). pattern_map_pair({map_field_exact,L,K,V}, St) -> - {Ck,[],_} = expr(K,St), - #c_map_pair{anno=lineno_anno(L,St), - op=#c_literal{val=exact}, - key=Ck, - val=pattern(V,St)}. + %% guard against pre-expressions + %% i.e. keys like {atom, <<0:300>>} where + %% <<0:300>> becomes a pre-expression + case expr(K,St) of + {Ck,[],_} -> + #c_map_pair{anno=lineno_anno(L,St), + op=#c_literal{val=exact}, + key=Ck, + val=pattern(V,St)}; + _ -> erlang:throw(nomatch) + end. %% pat_bin([BinElement], State) -> [BinSeg]. |