[erlang-questions] Why the compiler doesn't complain!

Ali Yakout ali.yakout@REDACTED
Tue Jan 15 08:12:29 CET 2008


Hi,

I came across some strange compiler behavior.


The compiler should display a warning if some clause can't match because
the previous one do.
And this is true for the following:

-record(state, {name, accountNo, input, pin}).

eval(Command, Args) ->
    io:format("Executing ~p ... ~n", [Command]);
eval({quit}, _) ->
    done.

8> c("me").
me.erl:7: Warning: this clause cannot match because a previous clause at
line 5 always matches
{ok,me}


But, when adding a record to the match clause, it goes ok !

eval2(Command, #state{name = "erl"}) ->
    io:format("Executing ~p ... ~n", [Command]);
eval2({quit}, #state{name = "erl"}) ->
    done.

9> c("me").
{ok,me}



Regards,
Ali Yakout
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080115/aae2dbe7/attachment.htm>


More information about the erlang-questions mailing list