[erlang-bugs] Wrong dialyzer spec for erlang:process_info/2
Patrik Nyblom
pan@REDACTED
Fri Oct 19 17:24:05 CEST 2012
On 10/19/2012 05:04 PM, Michał Ptaszek wrote:
> 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?
In master branch, they are in $ERL_TOP/erts/preloaded/src/erlang.erl
You need to do a ./otp_build update_preloaded --no-commit and then a
make in $ERL_TOP to get it tested.
in maint branch, they are 'hardcoded' in erl_bif_types.erl in the hipe
application. My recommendation is to *not* go there...
>
> Thanks,
> Michal
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
Cheers,
/Patrik
More information about the erlang-bugs
mailing list