[erlang-questions] Temporarily violating record type constraints annoys dialyzer
Tue Nov 13 13:31:04 CET 2018
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 :)
Brujo Benavides <http://about.me/elbrujohalcon>
> On 13 Nov 2018, at 09:23, Fred Hebert <mononcqc@REDACTED> wrote:
> On 11/12, Krzysztof Jurewicz wrote:
>> A similar problem arises if we try to use record syntax to construct generators for property testing:
>> The tests pass, but Dialyzer complains. To silence it, we could rewrite the property as:
> That's interesting. I pretty much never run Dialyzer against test suites simply because there are cases where I want my tests to trigger failures and validate in/out of boundary conditions are being checked, sometimes to know if the right kind of exceptions is raised (or that the right logs are produced as side-effects)
> Every time I purposefully send in data that breaks boundaries and raises exceptions which end up part of my program's contract even if it isn't part of its type annotations, Dialyzer is guaranteed to never pass.
> One of the small unspoken "rules" or practices I have is to never run Dialyzer on test code because it never works super well for plenty of cases, particularly when your tests explicitly try to break things.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions