[erlang-questions] Dialyzer safe way to test failure
Fri Dec 12 15:46:37 CET 2014
One way which helps is when you know a function may not return is to
declare it of type no_return() which tells dialyzer that you know this
function may generate an error. It at least works for functions which
explicitly call erlang:error/1.
On 9 December 2014 at 18:30, Jay Nelson <jay@REDACTED> wrote:
> 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?
> > Robert
> 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
> of a different type from my exact match. For some reason I expected
> to handle this case since the return of the catch is a successful match
> the value and I mentally assumed the try/catch was one expression.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions