gen_statem:start_monitor dialyzer warning

Nalin Ranjan ranjanified@REDACTED
Mon Jan 25 19:09:28 CET 2021


I am guessing that changing here
<https://github.com/erlang/otp/blob/master/lib/kernel/src/net.erl#L221>
should suffice. If you think otherwise please let me know. Or is it like
that because of "ifdef(USE_ESOCK)"?

Thanks and Regards
Nalin Ranjan

On Mon, Jan 25, 2021 at 11:14 PM Nalin Ranjan <ranjanified@REDACTED> wrote:

> Hi Raimo,
>
>  A little help if you could please point me to some starter.
>
> The type-spec of net:getnameinfo
> <https://erlang.org/doc/man/net.html#getnameinfo-2> can be made better as
> currently the type of SockAddr = term() is provided, which can be made even
> more explicit. An example is in the same file in the type declaration of
> ifaddrs() <https://erlang.org/doc/man/net.html#type-ifaddrs>, the field addr
> := socket:sockaddr()
> <https://erlang.org/doc/man/socket.html#type-sockaddr>
>
> I wanted to change it and raise a pull request, but not sure where can I.
> Can you please help me with some pointers. Rest I can follow.
>
> Thanks and Regards
> Nalin Ranjan
>
> On Mon, Jan 25, 2021 at 5:22 PM Raimo Niskanen <
> raimo+erlang-questions@REDACTED> wrote:
>
>> On Sun, Jan 24, 2021 at 02:31:54PM +0100, Kostis Sagonas wrote:
>> > On 1/24/21 2:14 PM, Matt Kowalczyk wrote:
>> > > Having a hard time understanding why the following sample code
>> generates
>> > > a dialyzer warning,
>> >
>> > Either because somebody added wrong specs to 'gen_statem' or forgot to
>> > update the specs of 'gen'.
>>
>> There is room for improvement here.
>>
>> We have a few Issues reported to bugs.erlang.org regarding type exports
>> from gen_server and gen_statem, and internal discussions have not
>> completed
>> on how much types that would be useful to export...
>>
>> Here gen does not export the right type for gen:start(_, monitor, ...).
>> I am not sure that we should specify types in gen; it is an internal
>> module,
>> so maybe it would be better to rely on Dialyzer figuring them out
>> instead...
>>
>> Also gen_statem exports start_ret() but not start_mon_ret().  That is not
>> consistent.
>>
>> Cheers
>> / Raimo
>>
>>
>> >
>> >
>> > ===== gen_statem has these types and specs =====
>> >
>> > -type start_mon_ret() ::
>> >          {'ok', {pid(),reference()}}
>> >        | 'ignore'
>> >        | {'error', term()}.
>> >
>> > -spec start_monitor(
>> >       Module :: module(), Args :: term(), Opts :: [start_opt()]) ->
>> >                  start_mon_ret().
>> > start_monitor(Module, Args, Opts) ->
>> >      gen:start(?MODULE, monitor, Module, Args, Opts).
>> >
>> >
>> > ===== gen:start/5's return type is: ======
>> >
>> > -type start_ret()  :: {'ok', pid()} | 'ignore' | {'error', term()}.
>> >
>> >
>> > Their intersection is: 'ignore' | {'error', term()}.
>> >
>> >
>> > Dialyzer is never wrong (C), but wrong specs can cause confusion.
>> >
>> > Kostis
>>
>> --
>>
>> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210125/c0408f9a/attachment.htm>


More information about the erlang-questions mailing list