aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-03-04 23:36:18 +0100
committerAnthony Ramine <[email protected]>2014-03-04 23:37:09 +0100
commit2b5acdb32471f2eb469221007fc70dc24db271b6 (patch)
tree03211875c8c8b23dba7b6bc5a281702808bef3d2 /lib/compiler/src
parentc199bd2923e7d733e60beb9bd27b3852cbb2e699 (diff)
downloadotp-2b5acdb32471f2eb469221007fc70dc24db271b6.tar.gz
otp-2b5acdb32471f2eb469221007fc70dc24db271b6.tar.bz2
otp-2b5acdb32471f2eb469221007fc70dc24db271b6.zip
Support maps in cerl_clauses:match/2
Without this, sys_core_fold could crash on non-matching clauses using maps patterns. Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/cerl_clauses.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/compiler/src/cerl_clauses.erl b/lib/compiler/src/cerl_clauses.erl
index 99fa8dd9d5..76d70dcabf 100644
--- a/lib/compiler/src/cerl_clauses.erl
+++ b/lib/compiler/src/cerl_clauses.erl
@@ -354,6 +354,24 @@ match(P, E, Bs) ->
{false, Bs}
end
end;
+ map ->
+ %% The most we can do is to say "definitely no match" if a
+ %% binary pattern is matched against non-binary data.
+ case E of
+ any ->
+ {false, Bs};
+ _ ->
+ case type(E) of
+ literal ->
+ none;
+ cons ->
+ none;
+ tuple ->
+ none;
+ _ ->
+ {false, Bs}
+ end
+ end;
_ ->
match_1(P, E, Bs)
end.