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

Bjorn Gustavsson bjorn@REDACTED
Tue Jan 15 11:29:08 CET 2008


"Ali Yakout" <ali.yakout@REDACTED> writes:

> The compiler should display a warning if some clause can't match because
> the previous one do.

The compiler does not guarantee that the compiler will display a
warning for every clause that cannot be reached. The compiler will
only display a warning if it is smart enough to see that the second
clause cannot match.

> 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.

The compiler is not smart enough in this case.

Dialyzer may handle this better.

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



More information about the erlang-questions mailing list