diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-04-02 17:00:43 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-04-03 14:32:44 +0200 |
commit | cc7a3c5896bc266bb97287dd4e31b696d8cf604f (patch) | |
tree | d19e07f7b30e2723184e1789f9113f6060428a15 /lib/compiler/src/v3_core.erl | |
parent | eba291a52d4a78c128c5802775fa1bff187e0604 (diff) | |
download | otp-cc7a3c5896bc266bb97287dd4e31b696d8cf604f.tar.gz otp-cc7a3c5896bc266bb97287dd4e31b696d8cf604f.tar.bz2 otp-cc7a3c5896bc266bb97287dd4e31b696d8cf604f.zip |
compiler,stdlib: Fix Map literals as keys for Maps in patterns
Diffstat (limited to 'lib/compiler/src/v3_core.erl')
-rw-r--r-- | lib/compiler/src/v3_core.erl | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index a548ba2f7c..8c18f6a9f7 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -1605,26 +1605,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) -> - %% 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 -> - %% this will throw a cryptic error message - %% but it is better than nothing - throw(nomatch); - Bin -> - #c_literal{anno=lineno_anno(L,St),val=Bin} - end; + case expr(K,St) of + {#c_literal{}=Key,_,_} -> + #c_map_pair{anno=lineno_anno(L, St), + op=#c_literal{val=exact}, + key=Key, + val=pattern(V, St)}; _ -> - pattern(K,St) - end, - #c_map_pair{anno=lineno_anno(L, St), - op=#c_literal{val=exact}, - key=Key, - val=pattern(V, St)}. - + %% this will throw a cryptic error message + %% but it is better than nothing + throw(nomatch) + end. %% pat_bin([BinElement], State) -> [BinSeg]. |