[erlang-bugs] Dialyzer crash on simple list types

Witold Baryluk baryluk@REDACTED
Mon Nov 28 01:30:44 CET 2011


Hi,

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).

-module(bug_dialyzer).
-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

gives:

$ 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}},
   [{erl_types,t_subst,3},{erl_types,t_subst,3},{erl_types,t_subst,3},
    {dialyzer_contracts,general_domain,2},
    {dialyzer_contracts,'-process_contract_remote_types/1-fun-0-',4},
    {dict...


dialyzer: Analysis failed with error: {{badmatch,{c,list,[any,any],nonempty}},
 [{erl_types,t_subst,3},
  {erl_types,t_subst,3},
  {erl_types,t_subst,3},
  {dialyzer_contracts,general_domain,2},
  {dialyzer_contracts,'-process_contract_remote_types/1-fun-0-',4},
  {dict,map_bucket,2},
  {dict,map_bkt_list,...},
  {dict,...}]}
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
crash.

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