Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
3191-Eliminate-false-warning-for-re-defined-and...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 3191-Eliminate-false-warning-for-re-defined-and-unused-ty.patch of Package erlang
From f7c11e4e4c4e9c11bf0c319fe24c5491de30120e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Mon, 13 Mar 2023 14:02:41 +0100 Subject: [PATCH] Eliminate false warning for re-defined and unused type Closes #6997 --- lib/stdlib/src/erl_lint.erl | 7 +++++- lib/stdlib/test/erl_lint_SUITE.erl | 34 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 728f82b518..959c04184a 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -3066,7 +3066,12 @@ check_type_2({type, Anno, TypeName, Args}, SeenVars, St) -> add_warning(Anno, W, St) end; _ -> - St + case is_default_type(TypePair) of + true -> + used_type(TypePair, Anno, St); + false -> + St + end end, check_type_2({type, nowarn(), product, Args}, SeenVars, St1); check_type_2({user_type, A, TypeName, Args}, SeenVars, St) -> diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 93595459d4..3d5f081cc5 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -5095,7 +5095,39 @@ redefined_builtin_type(Config) -> {{5,16},erl_lint,{redefine_builtin_type,{port,0}}}, {{6,16},erl_lint,{redefine_builtin_type,{float,0}}}, {{7,16},erl_lint,{redefine_builtin_type,{iodata,0}}} - ]}} + ]}}, + {redef6, + <<"-spec bar(function()) -> bar(). + bar({function, F}) -> F(). + -type function() :: {function, fun(() -> bar())}. + -type bar() :: {bar, binary()}. + ">>, + [], + {warnings,[{{3,16},erl_lint, + {redefine_builtin_type,{function,0}}}]}}, + {redef7, + <<"-type function() :: {function, fun(() -> bar())}. + -type bar() :: {bar, binary()}. + -spec bar(function()) -> bar(). + bar({function, F}) -> F(). + ">>, + [], + {warnings,[{{1,22},erl_lint, + {redefine_builtin_type,{function,0}}}]}}, + {redef8, + <<"-type function() :: {function, fun(() -> atom())}. + ">>, + [], + {warnings,[{{1,22},erl_lint, + {redefine_builtin_type,{function,0}}}, + {{1,22},erl_lint, + {unused_type,{function,0}}}]}}, + {redef9, + <<"-spec foo() -> fun(). + foo() -> fun() -> ok end. + ">>, + [], + []} ], [] = run(Config, Ts), ok. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor