[erlang-questions] Erlang dialyzer warnings for internal functions.

Guilherme Andrade g@REDACTED
Sun Apr 28 23:19:13 CEST 2019


Hello Wei,

On Sun, 28 Apr 2019 at 21:38, WW <kingwang98@REDACTED> wrote:

> Why dialyzer did not complain when  I  exported the function validator/1 ?
>
> It means exported function allowing never reach the calls ?
>

Because when you export said function, Dialyzer can't assume it won't be
called from code outside its analysis scope (e.g. modules in uncovered
apps, modules loaded in runtime, function references generated in run time,
the shell, ..) and so it can't determine the full range of possible
arguments - anything goes. And if anything goes, there's no way of saying:
"this particular execution flow will never happen."

Which is usually not the case with internal functions, where all possible
calling arguments /may/ be known when performing analysis, depending on
your code and how precisely Dialyzer can track type constraints in it.



>
>
> On Sunday, April 28, 2019, 9:30:03 PM GMT+2, Kostis Sagonas <
> kostis@REDACTED> wrote:
>
>
> On 4/28/19 6:41 PM, WW wrote:
>
> >
> > What is the best solution to avoid dialyzer warnings meanwhile also
> > satisfy my use cases.?
>
> >
>
> One cannot really answer this question without knowing what your "use
> case(s)" really is.,,,
>
> If it really is the code example you posted, if you pay close attention
> to the warning that you get from dialyzer, dialyzer also tells you that
> the call validator([]), let alone validator(3), is actually unreachable
> code in your example.  This is because dialyzer discovers that the prior
> call (validator(undefined)) will throw an exit exception and
> control-flow will never reach the validator([]) (and validator(3)) calls.
>
> Once again, remember the slogan: "Dialyzer is never wrong."
>
> Kostis
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190428/635aae66/attachment.htm>


More information about the erlang-questions mailing list