Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
0804-erl_lint-Add-nowarn_unused_type-option.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0804-erl_lint-Add-nowarn_unused_type-option.patch of Package erlang
From ed31aef5639ae1a8911862c84006773e41c27fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Fri, 1 Nov 2019 13:08:33 +0100 Subject: [PATCH] erl_lint: Add nowarn_unused_type option --- lib/stdlib/src/erl_lint.erl | 11 ++++++++++- lib/stdlib/test/erl_lint_SUITE.erl | 30 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index d6cb57e392..54b0fbd999 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -556,6 +556,9 @@ start(File, Opts) -> {unused_function, bool_option(warn_unused_function, nowarn_unused_function, true, Opts)}, + {unused_type, + bool_option(warn_unused_type, nowarn_unused_type, + true, Opts)}, {bif_clash, bool_option(warn_bif_clash, nowarn_bif_clash, true, Opts)}, @@ -3150,7 +3153,13 @@ add_missing_spec_warnings(Forms, St0, Type) -> add_warning(L, {missing_spec,FA}, St) end, St0, Warns). -check_unused_types(Forms, #lint{usage=Usage, types=Ts, exp_types=ExpTs}=St) -> +check_unused_types(Forms, St) -> + case is_warn_enabled(unused_type, St) of + true -> check_unused_types_1(Forms, St); + false -> St + end. + +check_unused_types_1(Forms, #lint{usage=Usage, types=Ts, exp_types=ExpTs}=St) -> case [File || {attribute,_L,file,{File,_Line}} <- Forms] of [FirstFile|_] -> D = Usage#usage.used_types, diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index a8ed4b19db..38d07249fd 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -64,7 +64,8 @@ predef/1, maps/1,maps_type/1,maps_parallel_match/1, otp_11851/1,otp_11879/1,otp_13230/1, - record_errors/1]). + record_errors/1, + unused_type/1]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -84,7 +85,8 @@ all() -> too_many_arguments, basic_errors, bin_syntax_errors, predef, maps, maps_type, maps_parallel_match, otp_11851, otp_11879, otp_13230, - record_errors]. + record_errors, + unused_type]. groups() -> [{unused_vars_warn, [], @@ -915,7 +917,30 @@ unused_function(Config) when is_list(Config) -> [] = run(Config, Ts), ok. - + +%% Test warnings for unused types +unused_type(Config) when is_list(Config) -> + Ts = [{func1, + <<"-type foo() :: term().">>, + {[]}, %Tuple indicates no export_all + {warnings,[{1,erl_lint,{unused_type,{foo,0}}}]}}, + + %% Turn off warnings for unused types. + {func2, + <<"-type foo() :: term().">>, + {[nowarn_unused_type]}, %Tuple indicates no export_all + []}, + + %% Turn off warnings for unused types using a -compile() directive. + {func3, + <<"-compile(nowarn_unused_type). + -type foo() :: term().">>, + {[]}, %Tuple indicates no export_all + []}], + + [] = run(Config, Ts), + ok. + %% OTP-4671. Errors for unsafe variables. unsafe_vars(Config) when is_list(Config) -> Ts = [{unsafe1, -- 2.16.4
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