[erlang-questions] How to force dialyzer that a function will return?

Peti Gömöri gomoripeti@REDACTED
Sat Oct 13 18:37:07 CEST 2018


Hi Robby,

While violation of opacity of data types is a bad, bad thing to do, it wont
necessarily result in a crash at runtime. I guess that dialyzer by default
infers that inner() function's return success type is none() because of the
opacity violation, but I would like to override this, to allow inner() to
return something (any()). This way I could check discrepancies in other
parts of outer() function (and transitively the whole application)

thanks
Peter

On Sat, Oct 13, 2018 at 4:57 PM Robert Raschke <rtrlists@REDACTED>
wrote:

> Hi Peti,
>
> that dialyzer warning usually really means what it says, unfortunately
> without pointing out where exactly the path is that leads to "no return".
> In my experience, it is worth investigating where your code may end up with
> an error that leads to a crash. And not try to silence the warning.
>
> Cheers,
> Robby
>
>
> On Sat, 13 Oct 2018 15:01 Peti Gömöri, <gomoripeti@REDACTED> wrote:
>
>> Hi,
>>
>> Let's say I have a function that does a bad thing, but I now it will
>> actually return. I can use the `-dialyzer` module attribute to silence the
>> warning about the particular function, but is there any way to convince
>> dialyzer to ignore that warning and assume that the function will return
>> (and consequently all other functions calling it will also return).
>>
>> For example for the below module dialyzer still warns:
>> dt.erl:6: Function outer/0 has no local return
>>
>> ```
>> -module(dt).
>>  -export([outer/0]).
>>
>> -dialyzer({nowarn_function, inner/0}).
>>
>> outer() ->
>>     inner().
>>
>> inner() ->
>>     Dict = dict:new(),
>>     element(2, Dict).
>> ```
>>
>> (this is just an example, I dont want to decompose a dict)
>>
>> thanks
>> Peter
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181013/2cc4490b/attachment.htm>


More information about the erlang-questions mailing list