Re: Dialyzer: Trying to understand the origin of "no local return"
Jesper Louis Andersen <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAGrdgiUR5Em2sg4mwHtqXSv3o9me8bv8kQaKqF1e+Hu3C2+yOg@mail.gmail.com> |
On Fri, Apr 2, 2021 at 3:10 PM Thomas Depierre <[email protected]> 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.