[erlang-bugs] Dialyzer bug related to contract checking

Stavros Aronis aronisstav@REDACTED
Tue Apr 3 11:35:15 CEST 2012


Hi!

I have confirmed this bug and I will submit a patch for it soon. Thanks for
the report!

Stavros

On Sat, Mar 31, 2012 at 5:51 PM, Sebastian Egner <
sebastian.egner@REDACTED> wrote:

> 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)
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120403/af5dca64/attachment.htm>


More information about the erlang-bugs mailing list