From e2074da57e6dd9b68a39ae71771b28c8f704196f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 17 Mar 2010 16:04:52 +0100 Subject: compiler: Fix binary matching bug in the inliner The inliner incorrectly assumes that a literal cannot match a binary in code such as: t() -> bc(<<"string">>). bc(<>) -> [A|bc(T)]; bc(<<>>) -> []. The bug was introduced when binary literals were introduced. --- lib/compiler/src/cerl_clauses.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/compiler/src/cerl_clauses.erl b/lib/compiler/src/cerl_clauses.erl index 5f111a5e05..bb0f998931 100644 --- a/lib/compiler/src/cerl_clauses.erl +++ b/lib/compiler/src/cerl_clauses.erl @@ -338,10 +338,19 @@ match(P, E, Bs) -> if E =:= any -> {false, Bs}; true -> - case is_data(E) of - true -> + case type(E) of + literal -> + case is_bitstring(concrete(E)) of + false -> + none; + true -> + {false, Bs} + end; + cons -> none; - false -> + tuple -> + none; + _ -> {false, Bs} end end; -- cgit v1.2.3