Dialyzer: Trying to understand the origin of "no local return"

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Fri Apr 2 16:05:58 CEST 2021


On Fri, Apr 2, 2021 at 3:10 PM Thomas Depierre <depierre.thomas@REDACTED>
wrote:

>
> I understand the other possible "no_return" warnings here, but i do not
> understand what situations does "only_normal" and "both" means here and how
> they get differentiated. I tried to understand how Dialyzer get to this
> decision in the code before that, but i got bogged down.
>
>
In general, we are trying to detect how we return from the function, but
the analysis of dialyzer has figured out that we can't possibly return from
the function in any valid way. There are four cases:

'no_match' - we are in trouble because no clauses will ever match (because
of the analysis)
'no_explicit' - we can only terminate by means of an explicit exception,
the normal code flow will never return
'no_normal' - the common case. We don't have any of the two above cases,
but we still know that the function won't return ever.
'both' - we don't know if it's either no_explicit or no_normal. This occurs
because we find a function call M:F(A...) where one of M or F isn't a
literal (where literal refers to the Core Erlang notion of a literal
value). So we kind of throw the arms in the air and go "it can be both of
them, I don't know which, I give up!"

It might be interesting to discriminate between the two error cases and
report them slightly differently in the output. My guess, and this is just
a hunch, is that 'both' is a rare occurrence, and you aren't any wiser by
discriminating between the two cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210402/2ad429bb/attachment.htm>


More information about the erlang-questions mailing list