<div dir="ltr">Hi Raimo,<div><br></div><div> A little help if you could please point me to some starter.</div><div><br></div><div>The type-spec of <a href="https://erlang.org/doc/man/net.html#getnameinfo-2">net:getnameinfo</a> 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 <a href="https://erlang.org/doc/man/net.html#type-ifaddrs">ifaddrs()</a>, the field <span style="color:rgb(216,212,207);font-family:mono,Courier,monospace;font-size:16px;font-weight:700;background-color:rgb(25,27,28)">addr := </span><span class="gmail-bold_code gmail-bc-15" style="font-family:mono,Courier,monospace;font-weight:700;color:rgb(216,212,207);font-size:16px;background-color:rgb(25,27,28)"><a href="https://erlang.org/doc/man/socket.html#type-sockaddr" style="color:rgb(94,170,233);text-decoration-line:none">socket:sockaddr()</a></span></div><div><br></div><div>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.</div><div><br></div><div>Thanks and Regards</div><div>Nalin Ranjan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 25, 2021 at 5:22 PM Raimo Niskanen <<a href="mailto:raimo%2Berlang-questions@erlang.org">raimo+erlang-questions@erlang.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, Jan 24, 2021 at 02:31:54PM +0100, Kostis Sagonas wrote:<br>
> On 1/24/21 2:14 PM, Matt Kowalczyk wrote:<br>
> > Having a hard time understanding why the following sample code generates <br>
> > a dialyzer warning,<br>
> <br>
> Either because somebody added wrong specs to 'gen_statem' or forgot to <br>
> update the specs of 'gen'.<br>
<br>
There is room for improvement here.<br>
<br>
We have a few Issues reported to <a href="http://bugs.erlang.org" rel="noreferrer" target="_blank">bugs.erlang.org</a> regarding type exports<br>
from gen_server and gen_statem, and internal discussions have not completed<br>
on how much types that would be useful to export...<br>
<br>
Here gen does not export the right type for gen:start(_, monitor, ...).<br>
I am not sure that we should specify types in gen; it is an internal module,<br>
so maybe it would be better to rely on Dialyzer figuring them out instead...<br>
<br>
Also gen_statem exports start_ret() but not start_mon_ret().  That is not<br>
consistent.<br>
<br>
Cheers<br>
/ Raimo<br>
<br>
<br>
> <br>
> <br>
> ===== gen_statem has these types and specs =====<br>
> <br>
> -type start_mon_ret() ::<br>
>          {'ok', {pid(),reference()}}<br>
>        | 'ignore'<br>
>        | {'error', term()}.<br>
> <br>
> -spec start_monitor(<br>
>       Module :: module(), Args :: term(), Opts :: [start_opt()]) -><br>
>                  start_mon_ret().<br>
> start_monitor(Module, Args, Opts) -><br>
>      gen:start(?MODULE, monitor, Module, Args, Opts).<br>
> <br>
> <br>
> ===== gen:start/5's return type is: ======<br>
> <br>
> -type start_ret()  :: {'ok', pid()} | 'ignore' | {'error', term()}.<br>
> <br>
> <br>
> Their intersection is: 'ignore' | {'error', term()}.<br>
> <br>
> <br>
> Dialyzer is never wrong (C), but wrong specs can cause confusion.<br>
> <br>
> Kostis<br>
<br>
-- <br>
<br>
/ Raimo Niskanen, Erlang/OTP, Ericsson AB<br>
</blockquote></div>