[erlang-questions] Missing compile warning

Björn Gustavsson <>
Mon Mar 3 17:49:08 CET 2014


On Fri, Feb 28, 2014 at 10:08 PM, Vlad Dumitrescu <> wrote:
> Hi!
>
> On Fri, Feb 28, 2014 at 7:54 PM, tom kelly <> wrote:
>>
>> -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.
>
>
> Looks like a bug to me, especially since changing the first clause to
> my_function1(#my_rec{field1 = {tag, _}, field2 = _}) -> 1;
> gives a warning for the first function too.
>

It is perhaps a documentation bug.

Some warnings can be trusted 100 per cent.
For example, if there are no warnigs for unused variables
there are no unused variables.

The absence of warnings for clauses that
don't match does *not* mean that that all clauses
can be matched. It merely means that
the compiler (during optimisation and
pattern matching compilation) did not find
any clauses that obviously would not be
reached.

/Bjorn


-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list