[erlang-bugs] Eunit assert causes Dialyzer warning

Richard Carlsson carlsson.richard@REDACTED
Thu Mar 31 11:35:29 CEST 2016


Better late than never! This issue was pointed out to me again, and this
time I thought of a solution that makes Dialyzer shut up about these
things. Pull request here: https://github.com/erlang/otp/pull/1002

Note that this will also make Dialyzer stop complaining about things like
?assert(true), which can happen if you have expressions that depend on
conditional compilation.


        /Richard

2010-06-11 18:14 GMT+02:00 Magnus Henoch <magnus@REDACTED>:

> In R13B04 (and probably others), putting an Eunit ?assert in the code
> will sometimes cause a Dialyzer warning, as below.  This happens because
> the definition of the assert macro in eunit.hrl does an extra check for
> when the value is neither true nor false, but in this case Dialyzer can
> infer that the value must be either true or false.
>
> It would be nice if either Eunit or Dialyzer could be changed to not
> output this warning, so I don't get distracted from warnings that might
> indicate actual problems.
>
>
> $ cat > foo.erl
> -module(foo).
>
> -include_lib("eunit/include/eunit.hrl").
>
> -export([foo/1]).
>
> foo(X) ->
>   ?assert(is_list(X)),
>   X.
> $ dialyzer --src foo.erl
>   Checking whether the PLT /home/magnus/.dialyzer_plt is up-to-date... yes
>   Proceeding with analysis...
> foo.erl:8: The variable _ can never match since previous clauses
> completely covered the type 'false'
>  done in 0m0.57s
> done (warnings were emitted)
>
>
> --
> Magnus Henoch, magnus@REDACTED
> Erlang Solutions
> http://www.erlang-solutions.com/
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
>
>
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@REDACTED
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20160331/9378aa7f/attachment.htm>


More information about the erlang-bugs mailing list