[erlang-questions] Temporarily violating record type constraints annoys dialyzer

Loïc Hoguin essen@REDACTED
Tue Nov 13 13:59:19 CET 2018

On 11/13/18 1:44 PM, Fred Hebert wrote:
> On 11/13, Brujo Benavides wrote:
>> Funny… I do exactly the opposite thing.
>> Since many of my projects are libraries and dialyzer is mostly 
>> clueless on the correctness of exported function specs when it has no 
>> other code using them, I use the tests to let dialyzer know how the 
>> functions are meant to be used. That way it can tell me if my specs 
>> are wrong or if something I meant to do with those functions is 
>> actually not possible.
>> That’s why, more often than not, instead of `rebar3 dialyzer`, I do 
>> `rebar3 as test dialyzer`.
>> BTW, I don’t think Krzysztof was saying that he run dialyzer against 
>> tests, just that (on one hand) tests pass but (on the other hand) when 
>> he checked his code with dialyzer, it complained. Mostly because I can 
>> see how dialyzer would complain with just his code, and no tests :)
>> Cheers
>> Brujo Benavides <http://about.me/elbrujohalcon>
> Do you just not do negative tests or you silence each of them individually?

I personally silence both Dialyzer warnings in expected test failures 
(for example Cowboy handler crashes) and any error/crash logs that would 
be produced, if any. I've just a few weeks ago enabled Dialyzer against 
the Cowboy tests by default (whereas I was running it manually from time 
to time before) and this helped me fix a few bad types.

Sometimes Dialyzer needs to be silenced via disabling a warning on a 
specific function, sometimes adding a spec with no_return() is enough. 
Either way you can't really mix positive and negative tests in the same 
test function.


Loïc Hoguin

More information about the erlang-questions mailing list