[erlang-questions] incomplete union checks in dialyzer

Kostis Sagonas kostis@REDACTED
Thu Aug 30 11:51:58 CEST 2012


On 08/30/2012 11:38 AM, Motiejus Jakštys wrote:
> Hi,
>
> -module(gg).
> -export([oho/0]).
>
> -type(error_enum() ::
>        f01 | f02 | f03 | f04 | f05 | f06 | f07
>      | f08 | f09 | f10 | f11 | f12 | f13 | f14
> ).
>
> -spec oho() ->  error_enum().
> oho() ->  oh_no.
>
>
> $ erlc +debug_info gg.erl&&  dialyzer --no_check_plt gg.beam
>    Proceeding with analysis... done in 0m0.48s
> done (passed successfully)
>
> Which is wrong ('oh_no' is not part of error_enum()). However, if I
> remove "| f14`":
>
> $ erlc +debug_info gg.erl&&  dialyzer --no_check_plt gg.beam
>    Proceeding with analysis...
> gg.erl:9: Invalid type specification for function gg:oho/0. The
> success typing is () ->  'oh_no'
>   done in 0m0.51s
> done (warnings were emitted)
>
> Which is right. How come?
>

Both are right.

Dialyzer never promised that it will find all discrepancies in your 
code.  It only promised that /when/ it produces some warning, then that 
warning is correct.


Now, this particular behaviour happens because there is the following 
define in lib/hipe/cerl/erl_types.erl:

-define(SET_LIMIT, 13).

Make this bigger if you want and you will get more precise analysis 
results at the risk of increased analysis time.

Kostis



More information about the erlang-questions mailing list