diff options
author | Björn Gustavsson <[email protected]> | 2010-03-17 16:04:52 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-03-26 08:03:42 +0100 |
commit | e2074da57e6dd9b68a39ae71771b28c8f704196f (patch) | |
tree | b31951c40319107fa39e00e3b337a2da99193400 /lib/compiler/src/cerl_clauses.erl | |
parent | a2c88ff1875a2039c987c1099e6d911f1b6dfce6 (diff) | |
download | otp-e2074da57e6dd9b68a39ae71771b28c8f704196f.tar.gz otp-e2074da57e6dd9b68a39ae71771b28c8f704196f.tar.bz2 otp-e2074da57e6dd9b68a39ae71771b28c8f704196f.zip |
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:1,T/bits>>) -> [A|bc(T)];
bc(<<>>) -> [].
The bug was introduced when binary literals were introduced.
Diffstat (limited to 'lib/compiler/src/cerl_clauses.erl')
-rw-r--r-- | lib/compiler/src/cerl_clauses.erl | 15 |
1 files 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; |