Re: 17.0 : dialyzer issue on boolean type in record.

Ulf Wiger <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <[email protected]>
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 <[email protected]> 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
> [email protected]
> http://erlang.org/mailman/listinfo/erlang-bugs

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com



_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.