[erlang-bugs] Dialyzer bug related to contract checking

Sebastian Egner sebastian.egner@REDACTED
Sat Mar 31 17:51:28 CEST 2012


Hello,

The two modules a and b below seem to crash the Dialyzer in OTP R15B:

	./dialyzer --src a.erl b.erl

--> Error in process <0.29.0> with exit value: {{badmatch,{c,list,[any,any],nonempty}},[{erl_types,t_abstract_records,2,[{file,"erl_types.erl"},{line,3194}]},{erl_types,'-t_abstract_records/2-lc$^1/1-5-',2,[{file,"erl_types.erl"},{line,3204}]},{erl_types,'-t_abstract_records/2-lc$^1/1-5-'...

(Checking a.erl and b.erl individually is inconspicious.)

For a possible workaround, see below.

Sebastian


*Details*

Here is the reduced example:

% ---------------

-module(a).
-export([g/1]).

-export_type([a/0, t/0]).
-type a() :: integer().
-type t() :: a() | maybe_improper_list(t(), t()).

-spec g(t()) -> t().
g(X) -> X.

% ---

-module(b).
-export([f/1]).

-spec f(a:t()) -> a:t().
f(X) -> a:g(X).

% ---------------


*Workaround*

My understanding of the inner workings of Dialyzer is too limited to fix it at the quality needed to submit a patch directly through Github.

However, the following patch of t_abstract_records/2 in "otp_src_R15B/lib/hipe/cerl/erl_types.erl" corrects what is probably an "accidental match" against NewContents:

3194,3195c3194,3195
< 	  ?list(NewContents, NewTermination, _) = t_cons(NewContents, Other),
< 	  ?list(NewContents, NewTermination, Size)
---
> 	  ?list(NewContents2, NewTermination, _) = t_cons(NewContents, Other),
> 	  ?list(NewContents2, NewTermination, Size)




More information about the erlang-bugs mailing list