aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-08-18 18:45:26 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-08-26 12:12:48 +0200
commit4e84810eca640220a333f104d25412399b6c0d31 (patch)
tree0dd1d65317dc7afca245ded38cd5293f0d285b65 /lib/compiler
parent9870cec36b633c3787007e3acd6cebb03fa8545b (diff)
downloadotp-4e84810eca640220a333f104d25412399b6c0d31.tar.gz
otp-4e84810eca640220a333f104d25412399b6c0d31.tar.bz2
otp-4e84810eca640220a333f104d25412399b6c0d31.zip
compiler: Reintroduce binary limit for Map keys
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/v3_core.erl19
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].