[erlang-bugs] Dialyzer crash on simple list types

Witold Baryluk <>
Mon Nov 28 01:30:44 CET 2011


I was adding some specs to my code, and run dialyzer.

First I found that there is no
-type maybe_improper_list(T) :: maybe_improper_list(T, any()).
predefined (but it should be according to documentation).
Anyway, documentation doesn't exaclty define what 'maybe_' means.

Then I noticed dialyzer crashes, and after simiplication
found another problem.

Here is simplified test case (think about lists:split/2 function).

-spec s(maybe_improper_list(X, Z)) -> {list(X), maybe_improper_list(X, Z)}.
s(L) -> {L, L}.

It compiles without problem, but

dialyzer bug_dialyzer.erl


$ dialyzer bug_dialyzer.erl
  Checking whether the PLT /home/baryluk/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
=ERROR REPORT==== 28-Nov-2011::01:25:13 ===
Error in process <0.30.0> with exit value: {{badmatch,{c,list,[any,any],nonempty}},

dialyzer: Analysis failed with error: {{badmatch,{c,list,[any,any],nonempty}},
Last messages in the log cache:
  Reading files and computing callgraph... done in 0.23 secs
  Removing edges... done in 0.00 secs

I know maybe_improper_list/2 is discourced to use, and will
be probably removed, and instead one will need to use nonempty_improper_list/2,
and eventually define other types manually. But this not explains

Bug doesn't happen when I do not use polymorphic types,
also subsituting any() for Z above 
-spec s(maybe_improper_list(X, any())) -> {list(X), maybe_improper_list(X, any())}.
make it pass dialyzer.

Any ideas?

Witold Baryluk

More information about the erlang-bugs mailing list