[erlang-questions] Trouble with Erlang's lenient comparisons
Wed Apr 13 15:54:24 CEST 2011
> Thanks for the advice guys! I managed to get Dialyzer running and it
> worked very nicely; it managed to spot some unreachable code right off
> the bat :)
> However, it doesn't seem to get the more insidious errors that arise
> from comparing other types than was intended, i.e. accidentaly
> comparing a string to an integer... but since it's completely valid
> Erlang I guess it's not supposed to complain?
The answer depends on the kind of comparison that is used.
If by comparison you mean case expressions or direct matching as in
case String of
Integer -> ...
String = Integer
then dialyzer will report these to you as impossible matches.
If by comparison you mean uses of =/=, <, ... then of course these are
allowed in Erlang and of course dialyzer will not warn you that you are
doing something wrong there. (*)
(*) Though it will warn you that e.g. the 'false' clause is unreachable
in something like:
case String =\= Integer of
true -> ...
false -> ...
More information about the erlang-questions