diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2014-03-09 20:46:08 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2014-03-15 21:27:23 +0100 |
commit | 4185be0ad649bccb15bb67a15b618b6cc14fe253 (patch) | |
tree | 6b49268d3fb88b0eb4ea9dfc72354319b4715181 | |
parent | 5bc10a4ed286247274efa338b7d82b2d1f5534d6 (diff) | |
download | otp-4185be0ad649bccb15bb67a15b618b6cc14fe253.tar.gz otp-4185be0ad649bccb15bb67a15b618b6cc14fe253.tar.bz2 otp-4185be0ad649bccb15bb67a15b618b6cc14fe253.zip |
Fix evaluation of empty map patterns in erl_lint
Reported-by: José Valim
-rw-r--r-- | lib/stdlib/src/erl_eval.erl | 5 | ||||
-rw-r--r-- | lib/stdlib/test/erl_eval_SUITE.erl | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/stdlib/src/erl_eval.erl b/lib/stdlib/src/erl_eval.erl index 3974fbc4ec..acde3ad5d6 100644 --- a/lib/stdlib/src/erl_eval.erl +++ b/lib/stdlib/src/erl_eval.erl @@ -1123,9 +1123,10 @@ match1({tuple,_,Elts}, Tuple, Bs, BBs) match_tuple(Elts, Tuple, 1, Bs, BBs); match1({tuple,_,_}, _, _Bs, _BBs) -> throw(nomatch); -match1({map,_,Fs}, Map, Bs, BBs) -> +match1({map,_,Fs}, #{}=Map, Bs, BBs) -> match_map(Fs, Map, Bs, BBs); - +match1({map,_,_}, _, _Bs, _BBs) -> + throw(nomatch); match1({bin, _, Fs}, <<_/bitstring>>=B, Bs0, BBs) -> eval_bits:match_bits(Fs, B, Bs0, BBs, match_fun(BBs), diff --git a/lib/stdlib/test/erl_eval_SUITE.erl b/lib/stdlib/test/erl_eval_SUITE.erl index 7edf3d20a9..b91d14b5b8 100644 --- a/lib/stdlib/test/erl_eval_SUITE.erl +++ b/lib/stdlib/test/erl_eval_SUITE.erl @@ -1452,6 +1452,7 @@ eep43(Config) when is_list(Config) -> "end.", {#{a => b},#{a => c},#{a => b,d => e}}), error_check("[camembert]#{}.", {badarg,[camembert]}), + error_check("#{} = 1.", {badmatch,1}), ok. %% Check the string in different contexts: as is; in fun; from compiled code. |