erlang / otp

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

TypEr -T not working #5657

Open elbrujohalcon opened 2 years ago

elbrujohalcon commented 2 years ago

Describe the bug typer reports an error and blocks when trying to use the -T option.

To Reproduce

  1. Create these two files:
    • trusted.erl
      
      -module(trusted).

-export([trusted/0]).

-spec trusted() -> trusted. trusted() -> trusted.

* `untrusted.erl`
```erlang
-module(untrusted).

-export([untrusted/0]).

untrusted() ->
    trusted:trusted().
  1. Generate a PLT using dialyzer.
  2. Run the following command…
    typer --plt /path/to/your/plt -T untrusted.erl -T trusted.erl

    You'll see an error similar to…

    =ERROR REPORT==== 27-Jan-2022::12:06:24.499883 ===
    Error in process <0.84.0> with exit value:
    {{case_clause,
     {value,
         {{"trusted.erl",{5,2}},
          {contract,
              [{{c,function,
                   [{c,product,[],unknown},{c,atom,[trusted],unknown}],
                   unknown},
                []}],
              [],
              [{{type,
                    {5,14},
                    'fun',
                    [{type,{5,14},product,[]},{atom,{5,20},trusted}]},
                []}]},
          []}}},
    [{dialyzer_typesig,get_plt_constr,4,
      [{file,"dialyzer_typesig.erl"},{line,821}]},
    {dialyzer_typesig,handle_call,3,[{file,"dialyzer_typesig.erl"},{line,795}]},
    {dialyzer_typesig,handle_clauses_1,7,
      [{file,"dialyzer_typesig.erl"},{line,929}]},
    {dialyzer_typesig,handle_clauses,6,
      [{file,"dialyzer_typesig.erl"},{line,871}]},
    {dialyzer_typesig,traverse,3,[{file,"dialyzer_typesig.erl"},{line,357}]},
    {dialyzer_typesig,traverse_list,4,
      [{file,"dialyzer_typesig.erl"},{line,656}]},
    {dialyzer_typesig,traverse,3,[{file,"dialyzer_typesig.erl"},{line,389}]},
    {dialyzer_typesig,traverse_scc,4,
      [{file,"dialyzer_typesig.erl"},{line,206}]}]}

    …and the process will be blocked forever.

Expected behavior This result:

%% File: "untrusted.erl"
%% ---------------------
-spec untrusted() -> 'trusted'.

Affected versions I've experienced this issue in OTP 23.3.2 and OTP 24.0.2.

Additional context Running TypEr without -T works fine:

/tmp/annotate$ typer --plt $PLT untrusted.erl trusted.erl

%% File: "untrusted.erl"
%% ---------------------
-spec untrusted() -> 'trusted'.

%% File: "trusted.erl"
%% -------------------
-spec trusted() -> 'trusted'.
jhogberg commented 2 years ago

Thanks for your report! As with #5653, I don't think we have the time to fix this in the near future. Feel free to open a PR.