Re: gen_statem:start_monitor dialyzer warning

Nalin Ranjan <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CACE+zk+oWXs4U37tEo5VCdJ_hfWd2cX0Paa6WVD2PZxCpxErvg@mail.gmail.com>
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 <[email protected]> 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 <
> [email protected]> 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
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.