[erlang-questions] Warning not emitted on string matching clauses

Pierre Fenoll pierrefenoll@REDACTED
Wed Apr 1 20:42:50 CEST 2015

authenticate_nouns([{<<"user_auth">>, _}]) -> 'true';
authenticate_nouns([{<<"user_auth">>, [<<"recovery">>]}]) -> hi;
authenticate_nouns(_Nouns) -> 'false'.

In this code <https://gist.github.com/fenollp/c08e86bdf15b28552824> (or
above), the second clause will never match (because of source-order).
But erlc does not complain about it.

Ferd on IRC mentioned that the compiler might feel free to reorder clauses.
But the call wat_clauses:authenticate_nouns([{<<"user_auth">>,
returns true instead of hi, so no reordering is done.

Dialyzer does not complain either.

Am I right in thinking we should have a warning about a never matching

Pierre Fenoll
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150401/334b8d99/attachment.htm>

More information about the erlang-questions mailing list