[erlang-questions] Dialyzer: Why do I get a 'will never return success typing error' with this recursive function?
Jeremy Raymond
jeraymond@REDACTED
Fri Feb 24 14:33:50 CET 2012
[+ list]
I had also tried to indicate to dialyzer that this is the behaviour I'm looking for with this spec, but this didn't help either
-spec test(noloop | loop) -> no_return() | ok.
Dialyzer doesn't seem to be taking the specified return types into account as an indication of what is expected in this case.
On 2012-02-24, at 8:13 AM, Greg Fefelov wrote:
> Your first function can succeed with a certain argument, "noloop" in
> your case. But if you call it with "loop" as 1st parameter, it will
> never return. You may have forgotten to check if function that is
> virtually able to stop should actually stop. This may not be the
> behaviour you'd expect, so dialyzer warns you about it.
>
> Second function has loop deeper in the structure, you call another
> function that never returns. My best guess is dialyzer assumes you
> really expect that and it is not a mistake. Or it just doesn't track
> infinite functions being called from finite functions.
>
> 2012/2/24 Jeremy Raymond <jeraymond@REDACTED>:
>> Hello,
>>
>> When I dialyze this function
>>
>> test(noloop) ->
>> ok;
>> test(loop) ->
>> test(loop). % dialyzer warns about this call
>>
>> Dialyzer gives me the warning, "The call dialyzer_err:test('loop') will never return since it differs in the 1st argument from the success typing arguments: ('noloop')".
>>
>> If I move the recursive call to a different function the warning does away
>>
>> test(noloop) ->
>> ok;
>> test(loop) ->
>> do_loop(loop).
>>
>> do_loop(loop) ->
>> do_loop(loop).
>>
>> Functionally these look like they're doing the same thing to me. Why does dialyzer have issue with the first version of the function?
>>
>> --
>> Jeremy
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list