Skip to content

Commit

Permalink
Merge pull request #7597 from bjorng/bjorn/dialyzer/redefined-product…
Browse files Browse the repository at this point in the history
…-type/GH-7584/OTP-18738

dialyzer: Handle definition of type product/0
  • Loading branch information
bjorng authored Aug 31, 2023
2 parents e42163f + a8f5854 commit 62ef1b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dialyzer/src/dialyzer_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,13 @@ massage_forms([H | T], Defs) ->
massage_forms([], _Defs) ->
[].

massage_type({type, Loc, 'fun',
[{type, ArgsLoc, product, ArgTypes}, Ret0]},
Defs) ->
%% We must make sure that we keep the built-in `product` type here.
Args = {type, ArgsLoc, product, massage_type_list(ArgTypes, Defs)},
Ret = massage_type(Ret0, Defs),
{type, Loc, 'fun', [Args, Ret]};
massage_type({type, Loc, Name, Args0}, Defs) when is_list(Args0) ->
case sets:is_element({Name, length(Args0)}, Defs) of
true ->
Expand Down
13 changes: 13 additions & 0 deletions lib/dialyzer/test/small_SUITE_data/src/test_product_app.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-module(test_product_app).
-export([zero/0, one/1]).

-type mfa() :: integer().
-type product() :: binary().

-spec zero() -> any().
zero() ->
ok.

-spec one(mfa()) -> mfa().
one(I) when is_integer(I) ->
I * 42.

0 comments on commit 62ef1b0

Please sign in to comment.