[erlang-bugs] "cannot match" waning doesn't show in compilation stage

Илья Щербак <>
Mon Jul 29 06:19:04 CEST 2013


Hello,
there is a _no warnings_ when I try to compile the following code:

-module('1').

-record(record_1,{arg}).
-record(record_2,{}).

-export([foo/2]).

foo(#record_1{},#record_2{})->
    {ok,1};
foo(#record_1{arg=1},#record_2{}) ->
    {ok,2}.

:~/rep/vcs/apps/vcs_core/src$ erl
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:8:8] [async-threads:0]
[hipe] [kernel-poll:false]

Eshell V5.9.2  (abort with ^G)
1> c("1.erl").
{ok,'1'}


Otherwise when you try to compile a simpler code, something like this,
everything is fine:
-module('1').

-record(record_1,{arg}).
-record(record_2,{}).

-export([foo/2]).

foo(#record_1{},_)->
    {ok,1};
foo(#record_1{arg=1},#record_2{}) ->
    {ok,2}.

:~/rep/vcs/apps/vcs_core/src$ erl
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:8:8] [async-threads:0]
[hipe] [kernel-poll:false]

Eshell V5.9.2  (abort with ^G)
1> c("1.erl").
1.erl:17: Warning: this clause cannot match because a previous clause at
line 15 always matches
{ok,'1'}


There is should be a warning because the second case will never match so
far it included in first case. But it doesn't cover by warning message. It
can lead to a difficult logical problem.

With best Regards, Ilya.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20130729/966bf461/attachment.html>


More information about the erlang-bugs mailing list