[erlang-questions] Dialyzer safe way to test failure
Tue Dec 9 18:30:59 CET 2014
On Dec 8, 2014, at 6:44 PM, Robert Virding <rvirding@REDACTED> wrote:
> I have run into the same problem but I don't think there is anything you can do about it. Dialyzer is quite rightly informing you that you have a type error in your code, it is just unfortunate that that is what you are trying to test.
> Why are you checking your test suites?
I am dialyzing the test suites because I found that a quick and easy way to
fix simple typos and have had type errors in the past which weren’t readily
apparent just by compiling and running code. I may change that decision if
it creates more false positives than help for true positives.
> Original example case:
> true = try ?TM:reserve(atom_to_list(Cache_Name), Cache_Module)
> catch error:function_clause -> true
> j end,
In this case I am using try/catch on a single expression which returns a value
of a different type from my exact match. For some reason I expected dialyzer
to handle this case since the return of the catch is a successful match against
the value and I mentally assumed the try/catch was one expression.
More information about the erlang-questions