[erlang-questions] Lack of warning for overlapping clauses with

Björn Gustavsson bgustavsson@REDACTED
Thu Jul 22 12:11:21 CEST 2010


> I have gazed through the documentation and I have not found anything on the
> warnings that will be emitted by the compiler and what it will not detect.
> The things not detected should then be on the check list used when doing a
> code review since those things is where we still have a chance to make money
> as programmers.

There is some information that can be found
at the end of the documentation for compile:file/2
(after documentation of all options):

http://www.erlang.org/doc/man/compile.html#file-2

It would be possible to extend that section, but
a list of issues that will be detected could easily
become out-of-date and I don't think it is really
possible to list all issues it will not detect.


The purpose of the compiler is to generate good
code, not to inform you about mistakes in your program.

However, we noticed that some kind of blunders
were common, and that it would be trivial to produce
warnings about them during optimization or code
generation. For instance, since the compiler attempts
to evaluate constant expressions, it makes sense
to warn for expressions that will always fail, such
a 1/0. There is, however, no warning for X/0 since
the compiler does not try to evaluate that expression.

We want to the compiler to be as fast as possible,
so we don't want to add extra code to search for more
problems and produce more warnings. If you want to
find as many problems as possible before running
your code, use Dialyzer. It will do a much better job
that the compiler can ever hope to do.


I'll end with a quote from the documentation for
compile:file/2:

Obviously, the absence of warnings does not mean that there are no
remaining errors in the code.

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


More information about the erlang-questions mailing list