[erlang-bugs] 17.0 : dialyzer issue on boolean type in record.
Kostis Sagonas
kostis@REDACTED
Tue Jul 29 13:35:02 CEST 2014
On 07/29/2014 01:34 AM, PAILLEAU Eric wrote:
> Hi Steve,
>
> dialyzer is right, yes, in a sens, because the default value is not
> dynamically set, but what about below code ?
>
> dialyzer raise an error, because too smart, probably,
> while code is valid...
What you are experiencing (in your previous example) is due to your
test/1 function being module local, which allows dialyzer to infer that
all calls to it will be with a particular boolean value, not both.
Simply export it and the warning will disappear. If you want to have it
module local then what dialyzer tells you is that you can simplify its
code by taking out one clause of the case statement.
In the program you show below, dialyzer is also right. The ifdefs are
handled by the preprocessor and ONLY ONE branch is part of the code at
any dialyzer run, not both.
Kostis
> ---8<----------------------------------------------------
> -module(test).
>
> -export([test/0]).
>
> -ifdef(TEST).
> -record(test, { bool = 'true' :: boolean()} ).
> -else.
> -record(test, { bool = 'false' :: boolean()} ).
> -endif.
>
> test() -> test(#test{}).
>
> test(R) -> case R#test.bool of
> true -> true ;
> false -> false
> end.
> ---8<----------------------------------------------------
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
More information about the erlang-bugs
mailing list