Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/dialyzer/src/dialyzer_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ massage_type({type, Loc, 'fun',
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
case sets:is_element({Name, length(Args0)}, Defs) andalso
erl_internal:is_type(Name, length(Args0)) of
true ->
%% This name for a built-in type has been overriden locally
%% with a new definition.
Expand Down
25 changes: 25 additions & 0 deletions lib/dialyzer/test/small_SUITE_data/results/redefine_builtin_type
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

redefine_builtin_type.erl:54:2: Invalid type specification for function redefine_builtin_type:foo/1.
The success typing is redefine_builtin_type:foo(1) -> 'ok'
But the spec is redefine_builtin_type:foo(my_tuple()) -> 'ok'
They do not overlap in the 1st argument

%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2022-2026. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
33 changes: 32 additions & 1 deletion lib/dialyzer/test/small_SUITE_data/src/redefine_builtin_type.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2022-2026. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%

-module(redefine_builtin_type).
-export([lookup/2, verify_mfa/1, verify_pid/1]).
-export([lookup/2, verify_mfa/1, verify_pid/1, foo/1]).
-export_type([my_map/0, my_tuple/0]).

-type map() :: {atom(), erlang:map()}.

Expand All @@ -22,3 +43,13 @@ verify_mfa({M, F, A}) when is_atom(M), is_atom(F), is_integer(A) ->
-spec verify_pid(module()) -> 'ok'.
verify_pid(Pid) when is_pid(Pid) ->
ok.

-type map(_Type) :: map(). %% shadows the builtin map type
-type my_map() :: undefined | #{atom() => string()} | '_'.

-type tuple(_Type) :: integer().
-type my_tuple() :: {atom()}.

%% Should emit Dialyzer warning.
-spec foo(my_tuple()) -> ok.
foo(1) -> ok.
Loading