another bounds example - catched by normal compile but not by dialyzer

Bjorn Gustavsson bjorn@REDACTED
Tue Jun 27 09:56:30 CEST 2006


The reason for Dialyzer's strange messages is that the Beam compiler has
already replaced the failing expression/failing match with explicit code
to generate a badarg/badmatch (so that Dialyzer can't see the original code).

Therefore, it is probably a good idea to first fix all problems that the
compiler and xref can find before running Dialyzer.

/Bjorn

Roger Larsson <roger.larsson@REDACTED> writes:

> Furter experimentation:
> * Static checking of array bounds is a simpler problem than handling dynamic 
> lists.
> So, lets try the same kind of errors with tuples.
> 
> Normal compile detects these simple cases. But dialyzer
> return some strange messages.
> At least the dialyzer output is hard to decipher...
> 
> 	-module(bounds).
> 	-export([detect/0, wrong_match/0]).
> 
> 	detect() -> element(4, {1, 2, 3}).
> 	wrong_match() -> {_, _, _, _} = {1, 2, 3}.
> 
> > erl
> 1> c(bounds).
> ./bounds.erl:4: Warning: this expression would cause a 'badarg' exception at 
> run-time
> ./bounds.erl:5: Warning: this clause cannot match because of different 
> types/sizes
> {ok,bounds}
> 
> > dialyzer (from source)
> {bounds,detect,0}: Function has no local return
> {bounds,wrong_match,0}: Function has no local return
> 
> /RogerL
> 

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



More information about the erlang-questions mailing list