Eunit assert causes Dialyzer warning

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Eunit assert causes Dialyzer warning

Magnus Henoch-6
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, [hidden email]
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:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Eunit assert causes Dialyzer warning

Richard Carlsson-3
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 <[hidden email]>:
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, [hidden email]
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:[hidden email]



_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Loading...