[erlang-bugs] bug: missing warning statement

Joe Armstrong <>
Thu Apr 28 10:35:32 CEST 2011


%% How come no warnings for functions a .. c.
%% I'd expected a warning as in d

-module(bug).
-compile(export_all).

-define(IS_DIGIT(X),($0=<X andalso X=<$9)).

a([X|_]) when ?IS_DIGIT(X) -> a;
a("0x" ++ _) -> b.

b([X|_]) when $0=<X andalso X=<$9 -> a;
b("0x" ++ _) -> b.

c([X|_]) when X == $0 -> a;
c("0x" ++ _) -> b.

d([$0|_]) -> a;
d("0x" ++ _) -> b.


%% erlc bug.erl
%% ./bug.erl:16: Warning: this clause cannot match because a previous clause
at line 15 always matches

/Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20110428/a30c989a/attachment.html>


More information about the erlang-bugs mailing list