Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2021-dialyzer-Add-options-for-missing-extra-ran...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2021-dialyzer-Add-options-for-missing-extra-range-warning.patch of Package erlang
From f8644625853ebaf4aa90911e0f9d0f0ccad1a806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Thu, 9 Sep 2021 16:24:23 +0200 Subject: [PATCH] dialyzer: Add options for missing/extra range warnings These warnings are very useful on their own, and I think they're worth breaking out from the more chatty -Wunderspecs/-Woverspecs. --- lib/dialyzer/doc/src/dialyzer.xml | 20 ++++++++++++++++ lib/dialyzer/src/dialyzer.hrl | 2 ++ lib/dialyzer/src/dialyzer_contracts.erl | 4 ++-- lib/dialyzer/src/dialyzer_options.erl | 32 ++++++++++++++++++------- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/lib/dialyzer/doc/src/dialyzer.xml b/lib/dialyzer/doc/src/dialyzer.xml index 66281b201b..1b111b73ba 100644 --- a/lib/dialyzer/doc/src/dialyzer.xml +++ b/lib/dialyzer/doc/src/dialyzer.xml @@ -316,6 +316,16 @@ dialyzer --plts plt_1 ... plt_n -- files_to_analyze</code> <item> <p>Include warnings for functions that only return by an exception.</p> </item> + <tag><c>-Wextra_return</c> (***)</tag> + <item> + <p>Warn about functions that return values that are not part of the + specification.</p> + </item> + <tag><c>-Wmissing_return</c> (***)</tag> + <item> + <p>Warn about functions whose specification includes types that the + function cannot return.</p> + </item> <tag><c>-Wno_behaviours</c></tag> <item> <p>Suppress warnings about behavior callbacks that drift from the @@ -427,6 +437,16 @@ dialyzer --plts plt_1 ... plt_n -- files_to_analyze</code> specification is strictly more allowing than the success typing). </p> </item> + <tag><c>-Wno_extra_return</c></tag> + <item> + <p>Suppress warnings about functions that return values that are not + part of the specification.</p> + </item> + <tag><c>-Wno_missing_return</c></tag> + <item> + <p>Suppress warnings about functions whose specification includes types + that the function cannot return.</p> + </item> </taglist> </section> diff --git a/lib/dialyzer/src/dialyzer.hrl b/lib/dialyzer/src/dialyzer.hrl index 3ca63881d3..26ba0afea4 100644 --- a/lib/dialyzer/src/dialyzer.hrl +++ b/lib/dialyzer/src/dialyzer.hrl @@ -46,7 +46,9 @@ -define(WARN_CONTRACT_SYNTAX, warn_contract_syntax). -define(WARN_CONTRACT_NOT_EQUAL, warn_contract_not_equal). -define(WARN_CONTRACT_SUBTYPE, warn_contract_subtype). +-define(WARN_CONTRACT_MISSING_RETURN, warn_contract_missing_return). -define(WARN_CONTRACT_SUPERTYPE, warn_contract_supertype). +-define(WARN_CONTRACT_EXTRA_RETURN, warn_contract_extra_return). -define(WARN_CONTRACT_RANGE, warn_contract_range). -define(WARN_CALLGRAPH, warn_callgraph). -define(WARN_UNMATCHED_RETURN, warn_umatched_return). diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index 621ca88f1b..6b81fa5ac4 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -898,13 +898,13 @@ overlapping_contract_warning({M, F, A}, WarningInfo) -> extra_range_warning({M, F, A}, WarningInfo, ExtraRanges, STRange) -> ERangesStr = erl_types:t_to_string(ExtraRanges), STRangeStr = erl_types:t_to_string(STRange), - {?WARN_CONTRACT_SUPERTYPE, WarningInfo, + {?WARN_CONTRACT_EXTRA_RETURN, WarningInfo, {extra_range, [M, F, A, ERangesStr, STRangeStr]}}. missing_range_warning({M, F, A}, WarningInfo, ExtraRanges, CRange) -> ERangesStr = erl_types:t_to_string(ExtraRanges), CRangeStr = erl_types:t_to_string(CRange), - {?WARN_CONTRACT_SUBTYPE, WarningInfo, + {?WARN_CONTRACT_MISSING_RETURN, WarningInfo, {missing_range, [M, F, A, ERangesStr, CRangeStr]}}. picky_contract_check(CSig0, Sig0, MFA, WarningInfo, Contract, RecDict, diff --git a/lib/dialyzer/src/dialyzer_options.erl b/lib/dialyzer/src/dialyzer_options.erl index 44c75d60c1..dd90630b4b 100644 --- a/lib/dialyzer/src/dialyzer_options.erl +++ b/lib/dialyzer/src/dialyzer_options.erl @@ -338,20 +338,34 @@ build_warnings([Opt|Opts], Warnings) -> no_missing_calls -> ordsets:del_element(?WARN_CALLGRAPH, Warnings); specdiffs -> - S = ordsets:from_list([?WARN_CONTRACT_SUBTYPE, - ?WARN_CONTRACT_SUPERTYPE, - ?WARN_CONTRACT_NOT_EQUAL]), - ordsets:union(S, Warnings); + S = ordsets:from_list([?WARN_CONTRACT_SUBTYPE, + ?WARN_CONTRACT_SUPERTYPE, + ?WARN_CONTRACT_NOT_EQUAL, + ?WARN_CONTRACT_MISSING_RETURN, + ?WARN_CONTRACT_EXTRA_RETURN]), + ordsets:union(S, Warnings); overspecs -> - ordsets:add_element(?WARN_CONTRACT_SUBTYPE, Warnings); + S = ordsets:from_list([?WARN_CONTRACT_SUBTYPE, + ?WARN_CONTRACT_MISSING_RETURN]), + ordsets:union(S, Warnings); underspecs -> - ordsets:add_element(?WARN_CONTRACT_SUPERTYPE, Warnings); + S = ordsets:from_list([?WARN_CONTRACT_SUPERTYPE, + ?WARN_CONTRACT_EXTRA_RETURN]), + ordsets:union(S, Warnings); no_underspecs -> - ordsets:del_element(?WARN_CONTRACT_SUPERTYPE, Warnings); + ordsets:del_element(?WARN_CONTRACT_SUPERTYPE, Warnings); + extra_return -> + ordsets:add_element(?WARN_CONTRACT_EXTRA_RETURN, Warnings); + no_extra_return -> + ordsets:del_element(?WARN_CONTRACT_EXTRA_RETURN, Warnings); + missing_return -> + ordsets:add_element(?WARN_CONTRACT_MISSING_RETURN, Warnings); + no_missing_return -> + ordsets:del_element(?WARN_CONTRACT_MISSING_RETURN, Warnings); unknown -> - ordsets:add_element(?WARN_UNKNOWN, Warnings); + ordsets:add_element(?WARN_UNKNOWN, Warnings); OtherAtom -> - bad_option("Unknown dialyzer warning option", OtherAtom) + bad_option("Unknown dialyzer warning option", OtherAtom) end, build_warnings(Opts, NewWarnings); build_warnings([], Warnings) -> -- 2.31.1
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