[erlang-questions] Lack of warning for overlapping clauses with
Thu Jul 22 13:39:35 CEST 2010
2010/7/22 Björn Gustavsson <>
> > I have gazed through the documentation and I have not found anything on
> > warnings that will be emitted by the compiler and what it will not
> > The things not detected should then be on the check list used when doing
> > code review since those things is where we still have a chance to make
> > 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):
> 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.
Not 100% aligned with you on this, but I appreciate that you have a clear
policy and that you are following it.
That clarity alone is worth something.
> 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.
Given your clear mission above for the compiler it makes total sense to
delegate problem finding to Dialyzer - I will direct my findings and other
things to the Dialyzer team since I have a couple of ideas that might
> I'll end with a quote from the documentation for
> Obviously, the absence of warnings does not mean that there are no
> remaining errors in the code.
I appreciate that, but I still think that the mixing of when-clauses and
function clauses in my example is something that hits a grey zone, but now
that we have established the mission for the compiler (good code) I will put
my faith in Dialyzer instead when it comes to making my code clean.
> Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-questions