[erlang-questions] Missing compile warning

tom kelly <>
Fri Feb 28 19:54:08 CET 2014


Hi List,

Here's a stripped down & renamed version of some code I just copied from
our system. I may have been staring at this for too long but I've convinced
myself that the second function clause in both of these functions can never
be executed because they are both covered by the first function clause:


-module(no_warn).
-compile(export_all).

-record(my_rec,{field1, field2}).

my_function1(#my_rec{field1 = {tag, _}, field2 = f2}) -> 1;
my_function1(#my_rec{field1 = {tag, 1}, field2 = f2}) -> 2; % line 7
my_function1(_) -> 3.

my_function2(#my_rec{field1 = {tag, _}}) -> 1;
my_function2(#my_rec{field1 = {tag, 1}}) -> 2; % line11
my_function2(_) -> 3.


Except, that when I compile this (R16B03-1) the compiler only warns me
about one of them:


no_warn.erl:11: Warning: this clause cannot match because a previous clause
at line 10 always matches


Surely line 7 should give an identical warning? Or do I need to go lie down
for a little while?

//TTom.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140228/8f4df0fc/attachment.html>


More information about the erlang-questions mailing list