[erlang-bugs] Missing compile warning

Roberto Aloi prof3ta@REDACTED
Mon Mar 3 21:36:14 CET 2014


In case someone decides to have a look to this in more detail, a minimal
example follows.
A warning is raised for 'baz', but not for 'bar'.

-module(foo).

-export([bar/1, baz/1]).

bar({_,1}) -> ok;
bar({1,1}) -> ok.

baz({1,_}) -> ok;
baz({1,1}) -> ok.

KR,

Roberto

On Mon, Mar 3, 2014 at 4:37 PM, tom kelly <ttom.kelly@REDACTED> wrote:

>  Hi List,
>
> You've probably seen this on the questions mailing list, just re-posting
> here to follow the bug reporting guidelines:
>
>
> -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.
>
> When compiled on R16B03-1 this gives the output:
>
> no_warn.erl:11: Warning: this clause cannot match because a previous
> clause at line 10 always matches
>
> Ie. we are correctly warned about line 11 but not about line 7.
>
> //TTom.
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
>


-- 
Roberto Aloi
---
Website: http://roberto-aloi.com
Twitter: @robertoaloi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140303/7da223a2/attachment.htm>


More information about the erlang-bugs mailing list