aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/user_SUITE_data
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2016-06-08 13:13:04 +0200
committerStavros Aronis <[email protected]>2016-06-08 13:13:04 +0200
commitb13412d2e4331fa426a6722a04310cbcbf1731d6 (patch)
tree17fba1d7099d652eeab812b4b1a72e44cc9277bd /lib/dialyzer/test/user_SUITE_data
parentd26c15e07229c90ba8353bd78d5406ada0f13271 (diff)
downloadotp-b13412d2e4331fa426a6722a04310cbcbf1731d6.tar.gz
otp-b13412d2e4331fa426a6722a04310cbcbf1731d6.tar.bz2
otp-b13412d2e4331fa426a6722a04310cbcbf1731d6.zip
Fix a bug in Dialyzer related to call-site analysis
Dialyzer's "dataflow" module is using information from the callgraph to determine which functions may be called at a particular call-site. Unfortunately this information can include functions that are certainly not among the possible choices. We don't want to emit warnings in such cases, so a "reasonable" compromise is to stay silent if there are many possible funs and at least one of them can succeed. Bug reported by Dan Gudmundsson, test shrunk down by Magnus Lång.
Diffstat (limited to 'lib/dialyzer/test/user_SUITE_data')
-rw-r--r--lib/dialyzer/test/user_SUITE_data/results/wpc_hlines3
-rw-r--r--lib/dialyzer/test/user_SUITE_data/src/wpc_hlines.erl22
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/dialyzer/test/user_SUITE_data/results/wpc_hlines b/lib/dialyzer/test/user_SUITE_data/results/wpc_hlines
new file mode 100644
index 0000000000..d6e3f29ab9
--- /dev/null
+++ b/lib/dialyzer/test/user_SUITE_data/results/wpc_hlines
@@ -0,0 +1,3 @@
+
+wpc_hlines.erl:22: Function bad/1 has no local return
+wpc_hlines.erl:22: The pattern 'false' can never match the type 'true'
diff --git a/lib/dialyzer/test/user_SUITE_data/src/wpc_hlines.erl b/lib/dialyzer/test/user_SUITE_data/src/wpc_hlines.erl
new file mode 100644
index 0000000000..8c205a8247
--- /dev/null
+++ b/lib/dialyzer/test/user_SUITE_data/src/wpc_hlines.erl
@@ -0,0 +1,22 @@
+%% Bug reported by Dan Gudmundsson, test shrunk down by Magnus Lång.
+
+%% The problem is that dialyzer_dep generates edges from the fun
+%% application to both of the functions, and then during the warning pass
+%% dialyzer_dataflow:handle_apply_or_call generates warnings for any such
+%% edge that won't return.
+
+%% Since dialyzer_dep is currently supposed to overapproximate rather than
+%% underapproximate, the fix was to modify handle_apply_or_call to not generate
+%% warnings if some of the possible funs can succeed.
+
+-module(wpc_hlines).
+
+-export([do_export/0]).
+
+do_export() ->
+ {Proj, _} = % The culprit seems to be putting the funs in a tuple
+ {fun good/1, fun bad/1},
+ Proj(true).
+
+good(_) -> ok.
+bad(false) -> ok.