Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
5481-dialyzer-make-Wunknown-a-default-add-Wno_u...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5481-dialyzer-make-Wunknown-a-default-add-Wno_unknown-fla.patch of Package erlang
From e63c50e35a47e48d991be2951d0a78d01609319a Mon Sep 17 00:00:00 2001 From: Kiko Fernandez-Reyes <kiko@erlang.org> Date: Wed, 8 Feb 2023 08:30:48 +0100 Subject: [PATCH] dialyzer: make -Wunknown a default; add -Wno_unknown flag Dialyzer's warnings about unknown functions and types are enabled by default. Prior to this PR, Dialyzer used to have disabled (by default) warnings about unknown types and functions. This default value has been overwritten; Dialyzer now warns about unknown types and functions (as requested by the community in GH-5695). Thus, the following two examples are equivalent, i.e., passing the `-Wunknown` function is enabled by default: ```bash dialyzer moduler.erl -Wunknown -Wmissing_return dialyzer moduler.erl -Wmissing_return ``` Dialyzer has a new flag, `-Wno_unknown`. Its purpose is to supress warnings about unknown functions and types. Users who wish to suppress these warnings can invoke Dialyzer using this flag. Example: ```bash dialyzer module.erl -Wno_unknown ``` --- lib/dialyzer/doc/src/dialyzer.xml | 16 +++++----- lib/dialyzer/src/dialyzer.hrl | 1 + lib/dialyzer/src/dialyzer_cl_parse.erl | 12 +++---- lib/dialyzer/src/dialyzer_options.erl | 31 ++++++++++--------- lib/dialyzer/test/cplt_SUITE.erl | 29 ++++++++++------- lib/dialyzer/test/dialyzer_cl_SUITE.erl | 3 +- lib/dialyzer/test/dialyzer_common.erl | 7 ++++- lib/dialyzer/test/incremental_SUITE.erl | 15 ++++----- .../test/indent2_SUITE_data/dialyzer_options | 2 +- .../test/indent_SUITE_data/dialyzer_options | 2 +- lib/dialyzer/test/iplt_SUITE.erl | 28 +++++++++++------ .../test/line_SUITE_data/dialyzer_options | 2 +- .../test/map_SUITE_data/dialyzer_options | 2 +- .../test/opaque_SUITE_data/dialyzer_options | 2 +- .../test/options1_SUITE_data/dialyzer_options | 2 +- .../test/options2_SUITE_data/dialyzer_options | 2 +- .../test/r9c_SUITE_data/dialyzer_options | 2 +- .../test/small_SUITE_data/dialyzer_options | 2 +- .../underspecs_SUITE_data/dialyzer_options | 2 +- .../test/user_SUITE_data/dialyzer_options | 4 +-- lib/stdlib/src/erl_lint.erl | 2 +- 21 files changed, 95 insertions(+), 73 deletions(-) diff --git a/lib/dialyzer/doc/src/dialyzer.xml b/lib/dialyzer/doc/src/dialyzer.xml index 753c5f2257..34dd3e1f04 100644 --- a/lib/dialyzer/doc/src/dialyzer.xml +++ b/lib/dialyzer/doc/src/dialyzer.xml @@ -386,20 +386,18 @@ dialyzer --plts plt_1 ... plt_n -- files_to_analyze</code> <item> <p>Suppress warnings for unused functions.</p> </item> + <tag><c>-Wno_unknown</c></tag> + <item> + <p>Suppress warnings about unknown functions and types. The default is to + warn about unknown functions and types when setting the exit + status. When using Dialyzer from Erlang, warnings about unknown functions + and types are returned.</p> + </item> <tag><c>-Wunderspecs</c> (***)</tag> <item> <p>Warn about underspecified functions (the specification is strictly more allowing than the success typing).</p> </item> - <tag><c>-Wunknown</c> (***)</tag> - <item> - <p>Let warnings about unknown functions and types affect the - exit status of the command-line version. The default is to ignore - warnings about unknown functions and types when setting the exit - status. When using Dialyzer from Erlang, warnings about unknown - functions and types are returned; the default is not to return - these warnings.</p> - </item> <tag><c>-Wunmatched_returns</c> (***)</tag> <item> <p>Include warnings for function calls that ignore a structured return diff --git a/lib/dialyzer/src/dialyzer.hrl b/lib/dialyzer/src/dialyzer.hrl index 64cc844303..f34acb3410 100644 --- a/lib/dialyzer/src/dialyzer.hrl +++ b/lib/dialyzer/src/dialyzer.hrl @@ -126,6 +126,7 @@ | 'no_return' | 'no_undefined_callbacks' | 'no_underspecs' + | 'no_unknown' | 'no_unused' | 'underspecs' | 'unknown' diff --git a/lib/dialyzer/src/dialyzer_cl_parse.erl b/lib/dialyzer/src/dialyzer_cl_parse.erl index 4fac1df6a6..c955c9ea7d 100644 --- a/lib/dialyzer/src/dialyzer_cl_parse.erl +++ b/lib/dialyzer/src/dialyzer_cl_parse.erl @@ -594,6 +594,11 @@ warning_options_msg() -> -Wno_undefined_callbacks Suppress warnings about behaviours that have no -callback attributes for their callbacks. + -Wno_unknown + Suppress warnings about unknown functions and types. The default is to + warn about unknown functions and types when setting the exit + status. When using Dialyzer from Erlang, warnings about unknown functions + and types are returned. -Wunmatched_returns *** Include warnings for function calls which ignore a structured return value or do not match against one of many possible return value(s). @@ -610,13 +615,6 @@ warning_options_msg() -> of the specification. -Woverlapping_contract *** Warn about overloaded functions whose specification include types that overlap. - -Wunknown *** - Let warnings about unknown functions and types affect the - exit status of the command line version. The default is to ignore - warnings about unknown functions and types when setting the exit - status. When using the Dialyzer from Erlang, warnings about unknown - functions and types are returned; the default is not to return - such warnings. The following options are also available but their use is not recommended: (they are mostly for Dialyzer developers and internal debugging) diff --git a/lib/dialyzer/src/dialyzer_options.erl b/lib/dialyzer/src/dialyzer_options.erl index 326ad59afb..eb17036cfd 100644 --- a/lib/dialyzer/src/dialyzer_options.erl +++ b/lib/dialyzer/src/dialyzer_options.erl @@ -32,20 +32,21 @@ build(Opts) -> DefaultWarns = [?WARN_RETURN_NO_RETURN, - ?WARN_NOT_CALLED, - ?WARN_NON_PROPER_LIST, - ?WARN_FUN_APP, - ?WARN_MATCHING, - ?WARN_OPAQUE, - ?WARN_CALLGRAPH, - ?WARN_FAILING_CALL, - ?WARN_BIN_CONSTRUCTION, - ?WARN_MAP_CONSTRUCTION, - ?WARN_CONTRACT_RANGE, - ?WARN_CONTRACT_TYPES, - ?WARN_CONTRACT_SYNTAX, - ?WARN_BEHAVIOUR, - ?WARN_UNDEFINED_CALLBACK], + ?WARN_NOT_CALLED, + ?WARN_NON_PROPER_LIST, + ?WARN_FUN_APP, + ?WARN_MATCHING, + ?WARN_OPAQUE, + ?WARN_CALLGRAPH, + ?WARN_FAILING_CALL, + ?WARN_BIN_CONSTRUCTION, + ?WARN_MAP_CONSTRUCTION, + ?WARN_CONTRACT_RANGE, + ?WARN_CONTRACT_TYPES, + ?WARN_CONTRACT_SYNTAX, + ?WARN_BEHAVIOUR, + ?WARN_UNDEFINED_CALLBACK, + ?WARN_UNKNOWN], DefaultWarns1 = ordsets:from_list(DefaultWarns), InitPlt = dialyzer_plt:get_default_plt(), DefaultOpts = #options{}, @@ -429,6 +430,8 @@ build_warnings([Opt|Opts], Warnings) -> ordsets:del_element(?WARN_RETURN_NO_RETURN, Warnings); no_unused -> ordsets:del_element(?WARN_NOT_CALLED, Warnings); + no_unknown -> + ordsets:del_element(?WARN_UNKNOWN, Warnings); no_improper_lists -> ordsets:del_element(?WARN_NON_PROPER_LIST, Warnings); no_fun_app -> diff --git a/lib/dialyzer/test/dialyzer_cl_SUITE.erl b/lib/dialyzer/test/dialyzer_cl_SUITE.erl index ed84fc6068..49361c959d 100644 --- a/lib/dialyzer/test/dialyzer_cl_SUITE.erl +++ b/lib/dialyzer/test/dialyzer_cl_SUITE.erl @@ -56,7 +56,8 @@ call_to_missing_warning_includes_callsite(Config) when is_list(Config) -> {ok, BeamFileForPlt} = compile(Config, previously_defined, []), [] = dialyzer:run([{analysis_type, plt_build}, {files, [BeamFileForPlt]}, - {output_plt, Plt}]), + {output_plt, Plt}, + {warnings, [no_unknown]}]), {ok, Beam} = compile(Config, call_to_missing_example, []), Opts = diff --git a/lib/dialyzer/test/dialyzer_common.erl b/lib/dialyzer/test/dialyzer_common.erl index f7c00e3389..735e22e020 100644 --- a/lib/dialyzer/test/dialyzer_common.erl +++ b/lib/dialyzer/test/dialyzer_common.erl @@ -107,9 +107,14 @@ obtain_plt(PltFilename) -> build_plt(PltFilename) -> io:format("Building plt from scratch:"), + + %% build_plt/1 builds the plt using default warning options; -Wunknown is + %% enabled by default, so tests that do not satisfy -Wunknown will break. + %% for this reason, we must pass no_unknown in this analysis. + DefaultWarnings = {warnings, [no_unknown]}, try dialyzer:run([{analysis_type, plt_build}, {apps, ?required_modules}, - {output_plt, PltFilename}]) of + {output_plt, PltFilename}, DefaultWarnings]) of [] -> io:format("Successfully created plt!"), ok diff --git a/lib/dialyzer/test/indent2_SUITE_data/dialyzer_options b/lib/dialyzer/test/indent2_SUITE_data/dialyzer_options index ee07090337..726f8cca3a 100644 --- a/lib/dialyzer/test/indent2_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/indent2_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{warnings, [no_unused, no_return, specdiffs]}]}. +{dialyzer_options, [{warnings, [no_unused, no_return, no_unknown, specdiffs]}]}. diff --git a/lib/dialyzer/test/indent_SUITE_data/dialyzer_options b/lib/dialyzer/test/indent_SUITE_data/dialyzer_options index c14551a8ad..901581133f 100644 --- a/lib/dialyzer/test/indent_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/indent_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{warnings, [no_unused, no_return, overlapping_contract]}]}. +{dialyzer_options, [{warnings, [no_unused, no_return, no_unknown, overlapping_contract]}]}. diff --git a/lib/dialyzer/test/line_SUITE_data/dialyzer_options b/lib/dialyzer/test/line_SUITE_data/dialyzer_options index bba81934f5..ddb0191d10 100644 --- a/lib/dialyzer/test/line_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/line_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{error_location, line}, {warnings, [no_return]}]}. +{dialyzer_options, [{error_location, line}, {warnings, [no_return, no_unknown]}]}. diff --git a/lib/dialyzer/test/map_SUITE_data/dialyzer_options b/lib/dialyzer/test/map_SUITE_data/dialyzer_options index 1ddeb02c27..c8295d942d 100644 --- a/lib/dialyzer/test/map_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/map_SUITE_data/dialyzer_options @@ -1,2 +1,2 @@ -{dialyzer_options, [{indent_opt, false}]}. +{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown]}]}. {time_limit, 30}. diff --git a/lib/dialyzer/test/opaque_SUITE_data/dialyzer_options b/lib/dialyzer/test/opaque_SUITE_data/dialyzer_options index 8551a47541..08977cb46c 100644 --- a/lib/dialyzer/test/opaque_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/opaque_SUITE_data/dialyzer_options @@ -1,2 +1,2 @@ -{dialyzer_options, [{indent_opt, false}, {warnings, [no_unused, no_return]}]}. +{dialyzer_options, [{indent_opt, false}, {warnings, [no_unused, no_return, no_unknown]}]}. {time_limit, 40}. diff --git a/lib/dialyzer/test/options1_SUITE_data/dialyzer_options b/lib/dialyzer/test/options1_SUITE_data/dialyzer_options index ef5887a1eb..9e81465f95 100644 --- a/lib/dialyzer/test/options1_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/options1_SUITE_data/dialyzer_options @@ -1,2 +1,2 @@ -{dialyzer_options, [{indent_opt, false}, {include_dirs, ["my_include"]}, {defines, [{'COMPILER_VSN', 42}]}, {warnings, [no_improper_lists]}]}. +{dialyzer_options, [{indent_opt, false}, {include_dirs, ["my_include"]}, {defines, [{'COMPILER_VSN', 42}]}, {warnings, [no_improper_lists, no_unknown]}]}. {time_limit, 30}. diff --git a/lib/dialyzer/test/options2_SUITE_data/dialyzer_options b/lib/dialyzer/test/options2_SUITE_data/dialyzer_options index 6492098d01..7a0a1bec13 100644 --- a/lib/dialyzer/test/options2_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/options2_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{indent_opt, false}, {defines, [{'vsn', 4}]}, {warnings, [unknown, no_return]}]}. +{dialyzer_options, [{indent_opt, false}, {defines, [{'vsn', 4}]}, {warnings, [no_return]}]}. diff --git a/lib/dialyzer/test/r9c_SUITE_data/dialyzer_options b/lib/dialyzer/test/r9c_SUITE_data/dialyzer_options index ab6c9439ad..0e8219a34a 100644 --- a/lib/dialyzer/test/r9c_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/r9c_SUITE_data/dialyzer_options @@ -1,2 +1,2 @@ -{dialyzer_options, [{indent_opt, false}, {defines, [{vsn, 42}]}]}. +{dialyzer_options, [{indent_opt, false}, {defines, [{vsn, 42}]}, {warnings, [no_unknown]}]}. {time_limit, 20}. diff --git a/lib/dialyzer/test/small_SUITE_data/dialyzer_options b/lib/dialyzer/test/small_SUITE_data/dialyzer_options index 8a5cefaa1f..c154820022 100644 --- a/lib/dialyzer/test/small_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/small_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{indent_opt, false}, {error_location, column}, {warnings, [overlapping_contract]}]}. +{dialyzer_options, [{indent_opt, false}, {error_location, column}, {warnings, [no_unknown, overlapping_contract]}]}. diff --git a/lib/dialyzer/test/underspecs_SUITE_data/dialyzer_options b/lib/dialyzer/test/underspecs_SUITE_data/dialyzer_options index 1a9734deb2..99336b96d6 100644 --- a/lib/dialyzer/test/underspecs_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/underspecs_SUITE_data/dialyzer_options @@ -1 +1 @@ -{dialyzer_options, [{indent_opt, false}, {warnings, [underspecs]}]}. +{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown, underspecs]}]}. diff --git a/lib/dialyzer/test/user_SUITE_data/dialyzer_options b/lib/dialyzer/test/user_SUITE_data/dialyzer_options index 0a944966f0..5a30063ae7 100644 --- a/lib/dialyzer/test/user_SUITE_data/dialyzer_options +++ b/lib/dialyzer/test/user_SUITE_data/dialyzer_options @@ -1,2 +1,2 @@ -{dialyzer_options, [{indent_opt, false}]}. -{time_limit, 3}. \ No newline at end of file +{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown]}]}. +{time_limit, 3}. diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index b89f7cfc43..8eb329c79e 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -3414,7 +3414,7 @@ is_function_dialyzer_option(Option) -> is_module_dialyzer_option(Option) -> lists:member(Option, [no_return,no_unused,no_improper_lists,no_fun_app, - no_match,no_opaque,no_fail_call,no_contracts, + no_match,no_opaque,no_fail_call,no_contracts,no_unknown, no_behaviours,no_undefined_callbacks,unmatched_returns, error_handling,race_conditions,no_missing_calls, specdiffs,overspecs,underspecs,unknown, -- 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