[erlang-questions] [Q] dialyzer message: The pattern X can never match the type Y

Ladislav Lenart lenartlad@REDACTED
Wed May 28 17:16:31 CEST 2008


Hello,

first I'd like to say that dialyzer is a wonderful and
easy-to-use tool. It has already found several bugs for
me :-)

But I don't understand what dialyzer is trying to tell
me with a warning like:

   The pattern X can never match the type Y.

The actual code seems fine to me. It is similar to:

%%%%%%%%%%%%%%%%
-module(mod).

-export(f/1).

f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
     case Arg of
         foo -> x();
         _ -> y()
     end.
%%%%%%%%%%%%%%%%

However, dialyzer does not report a warning like:

   The pattern 'foo' can never match the type 'baz'

for the module above.

So I'd like to know what does the warning mean.

Thanks in advance,

Ladislav Lenart




More information about the erlang-questions mailing list