bad match question
Tue Jun 7 19:27:05 CEST 2005
Charles Blair wrote:
>>And yes, it would be nice if the compiler generated a warning for your
>>code, but it doesn't. The dialyzer probably does (I haven't tried).
> it doesn't (i tried before posting). thanks for your response.
In some sense the bug is too easy to find so Dialyzer misses it ;)
Dialyzer is working on an internal code format of the HiPE compiler, and
among other things this means that some compiler (HiPE compiler, that
is) optimizations have already occured when Dialyzer gets the code. One
of these things is a constant propagation. Unfortunately the constant
propagation discovers the badmatch and removes the matching completely,
leaving code to throw the appropriate exception (in order to preserve
the behaviour from the BEAM compiler). Dialyzer then finds that the
function can never return and warns about this, but it will not find the
matching that cannot succeed, because it is simply not there.
More information about the erlang-questions