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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Thomas Depierre
Hello,

In looking the source of Dialyzer "no local return", i find this code

In particular, i see that there are two types that can return this message. "only_normal" and "both".

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 particular, i do not understand what the tuple returned by find_terminals here https://github.com/erlang/otp/blob/master/lib/dialyzer/src/dialyzer_dataflow.erl#L3842 means.

Thank you for your help, would be greatly appreciated

Thomas Depierre
Reply | Threaded
Open this post in threaded view
|

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

Jesper Louis Andersen-2
On Fri, Apr 2, 2021 at 3:10 PM Thomas Depierre <[hidden email]> 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.