erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.35k stars 2.95k forks source link

dialyzer: erl_bif_types for erlang:system_info(logical_processors) is incomplete #8948

Open hizel opened 4 days ago

hizel commented 4 days ago

Describe the bug Incomplete type for erlang:system_info(logical_processors).

To Reproduce

-module(hi).
-export([hi/0]).
hi() ->
  unknown = erlang:system_info(logical_processors),
  ok.
$ dialyzer hi.erl
  Checking whether the PLT /home/hizel/.cache/erlang/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
hi.erl:6:1: Function hi/0 has no local return
hi.erl:7:3: The pattern 
          'unknown' can never match the type 
          non_neg_integer()
 done in 0m0.07s
done (warnings were emitted)

Expected behavior

dialyze without warnings

Affected versions 27.0.1 Erlang/OTP 27 [erts-15.0.1]

Additional context Also erl_bif_types.erl.erl dont contain spec for logical_processors_available/logical_processors_online

from erlang.erl

%% Note: changing the ordering number of a clause will change the docs!
%% Shadowed by erl_bif_types: erlang:system_info/1
-doc #{ group => system }.
-spec system_info
...
         (logical_processors |
          logical_processors_available |
          logical_processors_online) -> unknown | pos_integer();
-module(hi).
-export([hi/0]).
hi() ->
  hi = erlang:system_info(logical_processors_online),
  ok.
$ dialyzer hi.erl 
  Checking whether the PLT /home/hizel/.cache/erlang/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis... done in 0m0.06s
done (passed successfully)
garazdawi commented 3 days ago

Thanks for the report! Can you send a PR with a fix?