diff options
author | Hans Bolinder <[email protected]> | 2018-05-02 10:36:09 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2018-05-13 09:06:30 +0200 |
commit | ac35ee08779884728d67d804cc80b0c210c29fd8 (patch) | |
tree | 7cf09cec5736ee1b8acbc955a7597ae34cc56a3e /lib/dialyzer/test/small_SUITE_data | |
parent | 837fe8bf4bf3a567c66afec0f0ec3dd70d248cd8 (diff) | |
download | otp-ac35ee08779884728d67d804cc80b0c210c29fd8.tar.gz otp-ac35ee08779884728d67d804cc80b0c210c29fd8.tar.bz2 otp-ac35ee08779884728d67d804cc80b0c210c29fd8.zip |
dialyzer: Do not emit warnings for unreachable funs
Warnings are not generated for funs residing in dead code.
In particular, warnings like "The created fun has no local return" are
no longer generated for funs declared in clauses or functions that
cannot be run.
Diffstat (limited to 'lib/dialyzer/test/small_SUITE_data')
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/results/unused_funs | 5 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/unused_funs.erl | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/results/unused_funs b/lib/dialyzer/test/small_SUITE_data/results/unused_funs new file mode 100644 index 0000000000..c468457ead --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/results/unused_funs @@ -0,0 +1,5 @@ + +unused_funs.erl:10: The pattern 'error' can never match the type 'other_error' +unused_funs.erl:15: Function not_used/0 will never be called +unused_funs.erl:19: Function foo/1 will never be called +unused_funs.erl:7: Function test/0 has no local return diff --git a/lib/dialyzer/test/small_SUITE_data/src/unused_funs.erl b/lib/dialyzer/test/small_SUITE_data/src/unused_funs.erl new file mode 100644 index 0000000000..c24cf3ea81 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/unused_funs.erl @@ -0,0 +1,21 @@ +%% See also ERL-593. + +-module(unused_funs). + +-export([test/0]). + +test() -> % "has no local return" + Var = outer_scope, + case other_error of + error -> % "can never match" + %% No warnings "no local return" and "_ = 1 can never match 0" (!) + foo(fun() -> {Var, 1 = 0} end) + end. + +not_used() -> % "will never be called" + %% No warnings "no local return" and "1 can never match 0". + foo(fun() -> 1 = 0 end). + +foo(Fun) -> % "will never be called" + 1 = 0, % No pattern match warning (foo/1 is not traversed at all). + Fun(). |