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

Oscar Hellström oscar@REDACTED
Wed Jul 8 14:55:46 CEST 2009


Hi Maria,

Well, it doesn't help, since it will complain about line 14 calling
verify with the second argument not being an empty list. That's actually
what it's complaining about in the original version as well. And yes,
that call will never return, but that's kinda what I tried to express
with the return type ok | no_return()

Thanks

Maria Christakis wrote:
> 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
>


-- 
Oscar Hellström, oscar@REDACTED
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting Ltd
http://www.erlang-consulting.com/



More information about the erlang-questions mailing list