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

Krzysztof Jurewicz krzysztof.jurewicz@REDACTED
Tue Nov 13 20:57:57 CET 2018

Brujo Benavides writes:

> 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 :)

Actually I do run Dialyzer against tests, not only occasionally but routinely. Test code is also code and it can benefit from being checked by Dialyzer. Here is how it looks in the Ercoin repository (ABCI server):

• TEST_DIR is added to DIALYZER_DIRS: https://gitlab.com/Ercoin/ercoin/blob/0c6cedda6bdae870a70655524e008a80d1c1f170/Makefile#L46 . Therefore every invocation of make check and make dialyze (and also CI) covers test code.
• If ABCI client (Tendermint) sends malformed data, then it’s a bug on their side, so we can avoid blame if we crash.
• If end user sends invalid data (via ABCI client), then it is supported and we return a relevant error code. It is also tested; for example, there is a lengthy generator for creating invalid transaction binaries: https://gitlab.com/Ercoin/ercoin/blob/0c6cedda6bdae870a70655524e008a80d1c1f170/test/ercoin_tx_gen.erl#L266 .
• No throw expressions are used. If we parse data from a non-trustworthy data source and there is a possibility of early exit, nested case expressions or monads may be employed (though the latter not without issues, see https://github.com/fogfish/datum/issues/54 ).

More information about the erlang-questions mailing list