[erlang-bugs] 17.0 : dialyzer issue on boolean type in record.

PAILLEAU Eric eric.pailleau@REDACTED
Mon Jul 28 23:56:33 CEST 2014


Hi,
please considere below minimal module :
---8<----------------------------------------------------
-module(test).

-export([test/0]).

-record(test, { bool   = 'true' :: boolean()} ).

test() -> test(#test{}).

test(R) -> case R#test.bool of
                 true  -> ok ;
                 false -> ok
            end.
---8<----------------------------------------------------
dialyzer raise an error :

test.erl:11: The pattern 'false' can never match the type 'true'.

Looks like dialyzer considere #test.bool to be of type 'true' while it 
is of type boolean() and default value to 'true'.

Documentation says :
"In the presence of initial values for fields, the type must be declared 
after the initialization as in the following:

   -record(rec, {field1 = [] :: Type1, field2, field3 = 42 :: Type3}).

Naturally, the initial values for fields should be compatible with (i.e. 
a member of) the corresponding types. "


A bug, isn't it ?

Regards.




More information about the erlang-bugs mailing list