Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
5791-dialyzer-Add-test-for-extra_return-and-mis...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5791-dialyzer-Add-test-for-extra_return-and-missing_retur.patch of Package erlang
From 122aaa23f6317d02b4bf55910cf268ffa7ac96bc Mon Sep 17 00:00:00 2001 From: Gonzalo Bella <gonzalobfmp@gmail.com> Date: Thu, 9 Jun 2022 08:57:21 +0100 Subject: [PATCH 1/3] dialyzer: Add test for extra_return and missing_return These warnings were part of `overspecs` and `underspecs` but were split in https://github.com/erlang/otp/pull/5214 so they are probably already tested. But for convenience, I decided to create two suites for testing each of them so we have one for each warning. --- .../test/extra_return_SUITE_data/dialyzer_options | 1 + .../extra_return_SUITE_data/results/extra_return | 2 ++ .../extra_return_SUITE_data/src/extra_return.erl | 12 ++++++++++++ .../test/missing_return_SUITE_data/dialyzer_options | 1 + .../missing_return_SUITE_data/results/missing_return | 2 ++ .../missing_return_SUITE_data/src/missing_return.erl | 12 ++++++++++++ 6 files changed, 30 insertions(+) create mode 100644 lib/dialyzer/test/extra_return_SUITE_data/dialyzer_options create mode 100644 lib/dialyzer/test/extra_return_SUITE_data/results/extra_return create mode 100644 lib/dialyzer/test/extra_return_SUITE_data/src/extra_return.erl create mode 100644 lib/dialyzer/test/missing_return_SUITE_data/dialyzer_options create mode 100644 lib/dialyzer/test/missing_return_SUITE_data/results/missing_return create mode 100644 lib/dialyzer/test/missing_return_SUITE_data/src/missing_return.erl diff --git a/lib/dialyzer/test/extra_return_SUITE_data/dialyzer_options b/lib/dialyzer/test/extra_return_SUITE_data/dialyzer_options new file mode 100644 index 0000000000..c83f8d286d --- /dev/null +++ b/lib/dialyzer/test/extra_return_SUITE_data/dialyzer_options @@ -0,0 +1 @@ +{dialyzer_options, [{indent_opt, false}, {warnings, [extra_return]}]}. diff --git a/lib/dialyzer/test/extra_return_SUITE_data/results/extra_return b/lib/dialyzer/test/extra_return_SUITE_data/results/extra_return new file mode 100644 index 0000000000..63895a231d --- /dev/null +++ b/lib/dialyzer/test/extra_return_SUITE_data/results/extra_return @@ -0,0 +1,2 @@ + +extra_return.erl:7:2: The specification for extra_return:t1/0 states that the function might also return 'other' but the inferred return is boolean() diff --git a/lib/dialyzer/test/extra_return_SUITE_data/src/extra_return.erl b/lib/dialyzer/test/extra_return_SUITE_data/src/extra_return.erl new file mode 100644 index 0000000000..7c51512145 --- /dev/null +++ b/lib/dialyzer/test/extra_return_SUITE_data/src/extra_return.erl @@ -0,0 +1,12 @@ +-module(extra_return). + +-export([t1/0]). + + +% Should warn about having `undefined` as return value when it is not returned by the function +-spec t1() -> true | false | 'other'. +t1() -> + case rand:uniform(2) of + 1 -> true; + 2 -> false + end. diff --git a/lib/dialyzer/test/missing_return_SUITE_data/dialyzer_options b/lib/dialyzer/test/missing_return_SUITE_data/dialyzer_options new file mode 100644 index 0000000000..d7ee920ade --- /dev/null +++ b/lib/dialyzer/test/missing_return_SUITE_data/dialyzer_options @@ -0,0 +1 @@ +{dialyzer_options, [{indent_opt, false}, {warnings, [missing_return]}]}. diff --git a/lib/dialyzer/test/missing_return_SUITE_data/results/missing_return b/lib/dialyzer/test/missing_return_SUITE_data/results/missing_return new file mode 100644 index 0000000000..3f0464b680 --- /dev/null +++ b/lib/dialyzer/test/missing_return_SUITE_data/results/missing_return @@ -0,0 +1,2 @@ + +missing_return.erl:7:2: The success typing for missing_return:t1/0 implies that the function might also return 'false' but the specification return is 'true' diff --git a/lib/dialyzer/test/missing_return_SUITE_data/src/missing_return.erl b/lib/dialyzer/test/missing_return_SUITE_data/src/missing_return.erl new file mode 100644 index 0000000000..1f0dfe6176 --- /dev/null +++ b/lib/dialyzer/test/missing_return_SUITE_data/src/missing_return.erl @@ -0,0 +1,12 @@ +-module(missing_return). + +-export([t1/0]). + + +% Should warn about only having true when also false is returned +-spec t1() -> true. +t1() -> + case rand:uniform(2) of + 1 -> true; + 2 -> false + end. -- 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