From 2b5acdb32471f2eb469221007fc70dc24db271b6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 4 Mar 2014 23:36:18 +0100 Subject: 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 --- lib/compiler/src/cerl_clauses.erl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/compiler/src/cerl_clauses.erl') 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. -- cgit v1.2.3