[erlang-bugs] Wrong dialyzer spec for erlang:process_info/2

Michał Ptaszek erlang@REDACTED
Fri Oct 19 17:04:59 CEST 2012


Hey,

Let's define a function which is supposed to return us a list of links
for a given process:

-spec links(pid()) -> [port() | pid()].
links(Pid) ->
    {links, Links} = process_info(Pid, links),
    Links.

Now let's run the dialyzer on the beam file:

dialyzer -Wno_return -Wunderspecs --fullpath --plt .plt pi.beam
  Checking whether the PLT .plt is up-to-date... yes
  Proceeding with analysis...
pi.erl:5: Type specification pi:links(pid()) -> [port() | pid()] is a
supertype of the success typing: pi:links(pid()) -> [pid()]
 done in 0m1.45s
done (warnings were emitted)

However it's clearly not right. For instance:
(mynode@REDACTED)1> erlang:process_info(whereis(erl_prim_loader), links).
{links,[#Port<0.1>,<0.0.0>]}

I wanted to fix it by myself, however could not find the right place
to apply the patch. Where can I find specs for ERTS BIFs?

Thanks,
Michal



More information about the erlang-bugs mailing list