Skip to content

Commit

Permalink
Merge pull request erlang#9432 from lucioleKi/isabell/dialyzer/fix/er…
Browse files Browse the repository at this point in the history
…langGH-9427

Turn on no_opaque_union option by default in Dialyzer
  • Loading branch information
lucioleKi authored Feb 25, 2025
2 parents adaaf86 + 0d7dcd8 commit 0ba47c7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/dialyzer/src/dialyzer.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ the warning options.
| 'extra_return'
| 'no_extra_return'
| 'missing_return'
| 'no_missing_return'.
| 'no_missing_return'
| 'opaque_union'.
-doc """
Option `from` defaults to `byte_code`. Options `init_plt` and `plts` change the
default.
Expand Down
8 changes: 6 additions & 2 deletions lib/dialyzer/src/dialyzer_cl_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ cli() ->
no_behaviours, no_contracts, no_fail_call, no_fun_app, no_improper_lists,
no_match, no_missing_calls, no_opaque, no_return, no_undefined_callbacks,
no_underspecs, no_unknown, no_unused, underspecs, unknown, unmatched_returns,
overspecs, specdiffs, overlapping_contract, extra_return, no_extra_return, missing_return, no_missing_return]},
overspecs, specdiffs, overlapping_contract, extra_return, no_extra_return, missing_return,
no_missing_return, opaque_union]},
help => {<<"[-Wwarn]*">>, [<<"A family of options which selectively turn on/off warnings">>]}},
#{name => version, short => $v, long => "-version", type => boolean,
help => <<"Print the Dialyzer version and some more information and exit.">>},
Expand Down Expand Up @@ -349,7 +350,10 @@ warning_options_msg() ->
Warn about functions that return values that are not part
of the specification.
-Woverlapping_contract ***
Warn about overloaded functions whose specification include types that overlap.
Warn about overloaded functions whose specification include types that
overlap.
-Wopaque_union ***
Warn about potentially creating a union between opaques and non-opaques.
The following options are also available but their use is not recommended:
(they are mostly for Dialyzer developers and internal debugging)
Expand Down
1 change: 0 additions & 1 deletion lib/dialyzer/src/dialyzer_options.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ build(Opts) ->
?WARN_FUN_APP,
?WARN_MATCHING,
?WARN_OPAQUE,
?WARN_OPAQUE_UNION,
?WARN_CALLGRAPH,
?WARN_FAILING_CALL,
?WARN_BIN_CONSTRUCTION,
Expand Down
2 changes: 1 addition & 1 deletion lib/dialyzer/test/opaque_SUITE_data/dialyzer_options
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unused, no_return, no_unknown]}]}.
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unused, no_return, no_unknown, opaque_union]}]}.
{time_limit, 40}.
2 changes: 1 addition & 1 deletion lib/dialyzer/test/overspecs_SUITE_data/dialyzer_options
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{dialyzer_options, [{indent_opt, false}, {warnings, [overspecs]}]}.
{dialyzer_options, [{indent_opt, false}, {warnings, [overspecs, opaque_union]}]}.
2 changes: 1 addition & 1 deletion lib/dialyzer/test/r9c_SUITE_data/dialyzer_options
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{dialyzer_options, [{indent_opt, false}, {defines, [{vsn, 42}]}, {warnings, [no_unknown]}]}.
{dialyzer_options, [{indent_opt, false}, {defines, [{vsn, 42}]}, {warnings, [no_unknown, opaque_union]}]}.
{time_limit, 20}.
2 changes: 1 addition & 1 deletion lib/dialyzer/test/underspecs_SUITE_data/dialyzer_options
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown, underspecs]}]}.
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown, underspecs, opaque_union]}]}.
2 changes: 1 addition & 1 deletion lib/dialyzer/test/user_SUITE_data/dialyzer_options
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown]}]}.
{dialyzer_options, [{indent_opt, false}, {warnings, [no_unknown, opaque_union]}]}.
{time_limit, 3}.
6 changes: 3 additions & 3 deletions scripts/run-dialyzer
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ PLT="$(mktemp).plt"

set -x

$DIALYZER --build_plt --output_plt "$PLT" -Wunknown -Woverlapping_contract --apps $BASE_PLT $APP_PLT --statistics
$DIALYZER -n --plt "$PLT" -Wunknown -Wunmatched_returns -Woverlapping_contract --apps $UNMATCHED --statistics
$DIALYZER -n --plt "$PLT" -Wunknown -Woverlapping_contract --apps $NO_UNMATCHED --statistics
$DIALYZER --build_plt --output_plt "$PLT" -Wunknown -Woverlapping_contract -Wopaque_union --apps $BASE_PLT $APP_PLT --statistics
$DIALYZER -n --plt "$PLT" -Wunknown -Wunmatched_returns -Woverlapping_contract -Wopaque_union --apps $UNMATCHED --statistics
$DIALYZER -n --plt "$PLT" -Wunknown -Woverlapping_contract -Wopaque_union --apps $NO_UNMATCHED --statistics
if [ "X$WARNINGS" != "X" ]; then
$DIALYZER -n --plt "$PLT" --apps $WARNINGS --statistics || true
fi

0 comments on commit 0ba47c7

Please sign in to comment.