Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
8142-fixup-Add-options-for-silencing-warnings-f...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 8142-fixup-Add-options-for-silencing-warnings-for-behavio.patch of Package erlang
From b38327e81f7c75cfbec0d76fcd1c094d8a3de0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Fri, 8 Nov 2024 06:19:26 +0100 Subject: [PATCH 2/2] fixup! Add options for silencing warnings for behaviours --- lib/compiler/src/compile.erl | 3 +++ lib/stdlib/src/erl_lint.erl | 13 +++++++++++-- lib/stdlib/test/erl_lint_SUITE.erl | 27 +++++++++++++++++---------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml index 4f58a162be..10ddb07f07 100644 --- a/lib/compiler/doc/src/compile.xml +++ b/lib/compiler/doc/src/compile.xml @@ -934,6 +934,12 @@ module.beam: module.erl \ of such tuples.</p> </item> + <tag><c>nowarn_behaviours</c></tag> + <item> + <p>By default, warnings are emitted for issues with behaviours. + Use this option to turn off all warnings of this kind.</p> + </item> + <tag><c>nowarn_conflicting_behaviours</c></tag> <item> <p>By default, warnings are emitted when a module opts in to diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index b871e76491..b190225cbe 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -823,6 +823,10 @@ start(File, Opts) -> bool_option(warn_update_literal, nowarn_update_literal, true, Opts)}, %% Behaviour warnings. + {behaviours, + bool_option(warn_behaviours, + nowarn_behaviours, + true, Opts)}, {conflicting_behaviours, bool_option(warn_conflicting_behaviours, nowarn_conflicting_behaviours, @@ -1256,8 +1260,13 @@ post_traversal_check(Forms, St0) -> %% check_behaviour(State0) -> State %% Check that the behaviour attribute is valid. -check_behaviour(St0) -> - behaviour_check(St0#lint.behaviour, St0). +check_behaviour(St) -> + case is_warn_enabled(behaviours, St) of + true -> + behaviour_check(St#lint.behaviour, St); + false -> + St + end. %% behaviour_check([{Anno,Behaviour}], State) -> State' %% Check behaviours for existence and defined functions. diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index e1ca2ebe24..c51a91951a 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -3472,10 +3472,14 @@ behaviour_basic(Config) when is_list(Config) -> ], [] = run(Config, Ts), - Subst = #{behaviour1 => [nowarn_undefined_behaviour_func], - behaviour2 => [nowarn_undefined_behaviour_func], - behaviour4 => [nowarn_undefined_behaviour_func]}, + Subst0 = #{behaviour1 => [nowarn_undefined_behaviour_func], + behaviour2 => [nowarn_undefined_behaviour_func], + behaviour4 => [nowarn_undefined_behaviour_func]}, + [] = run(Config, rewrite(Ts, Subst0)), + + Subst = #{K => [nowarn_behaviours] || K := _ <- Subst0}, [] = run(Config, rewrite(Ts, Subst)), + ok. %% Basic tests with multiple behaviours. @@ -3781,13 +3785,16 @@ otp_11861(Conf) when is_list(Conf) -> ], [] = run(Conf, Ts), - Subst = #{otp_11861_1 => [nowarn_conflicting_behaviours], - otp_11861_11 => [nowarn_ill_defined_behaviour_callbacks], - otp_11861_12 => [nowarn_undefined_behaviour], - otp_11861_13 => [nowarn_undefined_behaviour], - otp_11861_17 => [nowarn_undefined_behaviour_callbacks], - otp_11861_19 => [nowarn_ill_defined_optional_callbacks] - }, + Subst0 = #{otp_11861_1 => [nowarn_conflicting_behaviours], + otp_11861_11 => [nowarn_ill_defined_behaviour_callbacks], + otp_11861_12 => [nowarn_undefined_behaviour], + otp_11861_13 => [nowarn_undefined_behaviour], + otp_11861_17 => [nowarn_undefined_behaviour_callbacks], + otp_11861_19 => [nowarn_ill_defined_optional_callbacks] + }, + [] = run(Conf, rewrite(Ts, Subst0)), + + Subst = #{K => [nowarn_behaviours] || K := _ <- Subst0}, [] = run(Conf, rewrite(Ts, Subst)), true = code:set_path(CodePath), -- 2.43.0
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