[erlang-questions] Dialyzer and erlang:error/1

Maria Christakis el03665@REDACTED
Wed Jul 8 14:34:46 CEST 2009


Hello,

I think that dialyzer assumes that no exception will ever be thrown.  
When you remove the specs, it comes up with:

-spec verify(['bar' | 'foo']) -> 'ok'.
-spec verify(['bar' | 'foo'],[]) -> 'ok'.

because no exception will be thrown when your Options list is either [] 
or contains 'foo' and / or 'bar' elements only. Then your Errors list 
will always be empty.

Hope this helped but a more educated opinion would be better,
Maria

Oscar Hellström wrote:
> Hi All,
>
> I'm trying to express that a valid list of options will return ok while
> any invalid option would eventually throw an exception, but Dialyzer and
> I don't get along.
>
> Dialyzer says:
> foo.erl:14: The call foo:verify(Options::any(),[any(),...]) will never
> return since it differs in argument position 2 from the success typing
> arguments: (['bar' | 'foo'],[])
>
> This is entirely true, but it's not an error, it's what I want! I guess
> I'm failing to express what I want here, so could anybody help me?
>
> Best regards
>
>   
> ------------------------------------------------------------------------
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org



More information about the erlang-questions mailing list