[erlang-bugs] 17.0 : dialyzer issue on boolean type in record.
Ulf Wiger
ulf@REDACTED
Tue Jul 29 13:26:39 CEST 2014
Dialyzer doesn’t consider ifdef alternatives in its analysis. The default mode is to analyze (debug-)compiled code, in which the ifdefs have already been resolved. You can tell dialyzer to start from the source code, but then, you need to provide values for the defines, using the -D flag*. See the dialyzer man page for details.
BR,
Ulf W
* For it to work otherwise, dialyzer would have to use its own preprocessor. As it is, dialyzer uses the standard compiler (using the undocumented option combo [to_pp, binary | _] to compile:file/2), and thus never sees the defines.
On 29 Jul 2014, at 00:34, PAILLEAU Eric <eric.pailleau@REDACTED> 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...
>
> This indeed imply to only set the type and not default value...
> Regards.
>
> ---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
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com
More information about the erlang-bugs
mailing list