[erlang-questions] Dialyzer safe way to test failure

Robert Virding rvirding@REDACTED
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
> 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.
> jay
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141212/6615ff82/attachment.htm>

More information about the erlang-questions mailing list