From 7554fad452171ec3dc0873ffdd09a24f6531b347 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Fri, 9 Dec 2011 11:54:10 +0100 Subject: Small fixes for Dialyzer's testsuites generation --- lib/dialyzer/test/Makefile | 2 +- lib/dialyzer/test/dialyzer_common.erl | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/Makefile b/lib/dialyzer/test/Makefile index 47deb17f1d..6a1abce943 100644 --- a/lib/dialyzer/test/Makefile +++ b/lib/dialyzer/test/Makefile @@ -30,5 +30,5 @@ release_tests_spec: $(INSTALL_DATA) $(AUXILIARY_FILES) $(RELSYSDIR) @tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -) cd $(RELSYSDIR);\ - erl -make;\ + erlc dialyzer_common.erl file_utils.erl;\ erl -noshell -run dialyzer_common create_all_suites -s erlang halt diff --git a/lib/dialyzer/test/dialyzer_common.erl b/lib/dialyzer/test/dialyzer_common.erl index 51766a4604..d2b1026c06 100644 --- a/lib/dialyzer/test/dialyzer_common.erl +++ b/lib/dialyzer/test/dialyzer_common.erl @@ -216,10 +216,13 @@ get_suites(Dir) -> end. suffix(String, Suffix) -> - Index = string:rstr(String, Suffix), - case string:substr(String, Index) =:= Suffix of - true -> {yes, string:sub_string(String,1,Index-1)}; - false -> no + case string:rstr(String, Suffix) of + 0 -> no; + Index -> + case string:substr(String, Index) =:= Suffix of + true -> {yes, string:sub_string(String,1,Index-1)}; + false -> no + end end. -spec create_suite(string()) -> 'ok'. -- cgit v1.2.3 From 8900a242fb35212b64b6b4246caa0ace128ca9b4 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Fri, 16 Dec 2011 13:37:16 +0100 Subject: Support alternative spelling of behaviour --- .../test/behaviour_SUITE_data/results/sample_behaviour | 16 ++++++++-------- .../src/sample_behaviour/sample_callback_wrong.erl | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/behaviour_SUITE_data/results/sample_behaviour b/lib/dialyzer/test/behaviour_SUITE_data/results/sample_behaviour index a38e662ccf..8cecabccaa 100644 --- a/lib/dialyzer/test/behaviour_SUITE_data/results/sample_behaviour +++ b/lib/dialyzer/test/behaviour_SUITE_data/results/sample_behaviour @@ -1,9 +1,9 @@ -sample_callback_wrong.erl:15: The inferred return type of sample_callback_2/0 (42) has nothing in common with atom(), which is the expected return type for the callback of sample_behaviour behaviour -sample_callback_wrong.erl:16: The inferred return type of sample_callback_3/0 ('fair') has nothing in common with 'fail' | {'ok',1..255}, which is the expected return type for the callback of sample_behaviour behaviour -sample_callback_wrong.erl:17: The inferred return type of sample_callback_4/1 ('fail') has nothing in common with 'ok', which is the expected return type for the callback of sample_behaviour behaviour -sample_callback_wrong.erl:19: The inferred return type of sample_callback_5/1 (string()) has nothing in common with 'fail' | 'ok', which is the expected return type for the callback of sample_behaviour behaviour -sample_callback_wrong.erl:19: The inferred type for the 1st argument of sample_callback_5/1 (atom()) is not a supertype of 1..255, which is expected type for this argument in the callback of the sample_behaviour behaviour -sample_callback_wrong.erl:21: The inferred return type of sample_callback_6/3 ({'okk',number()}) has nothing in common with 'fail' | {'ok',1..255}, which is the expected return type for the callback of sample_behaviour behaviour -sample_callback_wrong.erl:21: The inferred type for the 3rd argument of sample_callback_6/3 (atom()) is not a supertype of string(), which is expected type for this argument in the callback of the sample_behaviour behaviour -sample_callback_wrong.erl:3: Undefined callback function sample_callback_1/0 (behaviour 'sample_behaviour') +sample_callback_wrong.erl:16: The inferred return type of sample_callback_2/0 (42) has nothing in common with atom(), which is the expected return type for the callback of sample_behaviour behaviour +sample_callback_wrong.erl:17: The inferred return type of sample_callback_3/0 ('fair') has nothing in common with 'fail' | {'ok',1..255}, which is the expected return type for the callback of sample_behaviour behaviour +sample_callback_wrong.erl:18: The inferred return type of sample_callback_4/1 ('fail') has nothing in common with 'ok', which is the expected return type for the callback of sample_behaviour behaviour +sample_callback_wrong.erl:20: The inferred return type of sample_callback_5/1 (string()) has nothing in common with 'fail' | 'ok', which is the expected return type for the callback of sample_behaviour behaviour +sample_callback_wrong.erl:20: The inferred type for the 1st argument of sample_callback_5/1 (atom()) is not a supertype of 1..255, which is expected type for this argument in the callback of the sample_behaviour behaviour +sample_callback_wrong.erl:22: The inferred return type of sample_callback_6/3 ({'okk',number()}) has nothing in common with 'fail' | {'ok',1..255}, which is the expected return type for the callback of sample_behaviour behaviour +sample_callback_wrong.erl:22: The inferred type for the 3rd argument of sample_callback_6/3 (atom()) is not a supertype of string(), which is expected type for this argument in the callback of the sample_behaviour behaviour +sample_callback_wrong.erl:4: Undefined callback function sample_callback_1/0 (behaviour 'sample_behaviour') diff --git a/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_wrong.erl b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_wrong.erl index 02a063fab7..430494c48c 100644 --- a/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_wrong.erl +++ b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_wrong.erl @@ -1,6 +1,7 @@ -module(sample_callback_wrong). --behaviour(sample_behaviour). +%% This attribute uses the american spelling of 'behaviour'. +-behavior(sample_behaviour). -export([ % sample_callback_1/0, -- cgit v1.2.3 From 2f8daabdbdd3d03a4db8e1680a8b2773f0561d5e Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Thu, 22 Dec 2011 16:38:21 +0200 Subject: Allow t_opaque_structure to handle multiple opaque types --- .../test/opaque_SUITE_data/results/multiple_wrong_opaques | 2 ++ .../test/opaque_SUITE_data/src/multiple_wrong_opaques.erl | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 lib/dialyzer/test/opaque_SUITE_data/results/multiple_wrong_opaques create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/multiple_wrong_opaques.erl (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/opaque_SUITE_data/results/multiple_wrong_opaques b/lib/dialyzer/test/opaque_SUITE_data/results/multiple_wrong_opaques new file mode 100644 index 0000000000..18ece8820c --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/results/multiple_wrong_opaques @@ -0,0 +1,2 @@ + +multiple_wrong_opaques.erl:5: Invalid type specification for function multiple_wrong_opaques:weird/1. The success typing is ('gazonk') -> 42 diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/multiple_wrong_opaques.erl b/lib/dialyzer/test/opaque_SUITE_data/src/multiple_wrong_opaques.erl new file mode 100644 index 0000000000..9e695cec1d --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/multiple_wrong_opaques.erl @@ -0,0 +1,8 @@ +-module(multiple_wrong_opaques). + +-export([weird/1]). + +-spec weird(dict() | gb_tree()) -> 42. + +weird(gazonk) -> 42. + -- cgit v1.2.3 From 4ca72667f3e655d175c7587b8998aa7d22f50985 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Sun, 22 Jan 2012 17:43:48 +0100 Subject: Zero-arity unused functions Dialyzer patch Dialyzer was not reporting unused functions with 0 arity. This was not a real issue, until we found out that there could be cases where this could lead to false warnings. This was the case in "no_local_return.erl". --- lib/dialyzer/test/options1_SUITE_data/results/compiler | 1 + lib/dialyzer/test/r9c_SUITE_data/results/inets | 1 + lib/dialyzer/test/small_SUITE_data/results/cerl_hipeify | 2 +- lib/dialyzer/test/small_SUITE_data/results/inf_loop2 | 2 +- lib/dialyzer/test/small_SUITE_data/results/no_local_return | 3 +++ lib/dialyzer/test/small_SUITE_data/src/no_local_return.erl | 12 ++++++++++++ 6 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 lib/dialyzer/test/small_SUITE_data/results/no_local_return create mode 100644 lib/dialyzer/test/small_SUITE_data/src/no_local_return.erl (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/options1_SUITE_data/results/compiler b/lib/dialyzer/test/options1_SUITE_data/results/compiler index e82087ae86..6399e3e36b 100644 --- a/lib/dialyzer/test/options1_SUITE_data/results/compiler +++ b/lib/dialyzer/test/options1_SUITE_data/results/compiler @@ -20,6 +20,7 @@ cerl_inline.erl:2333: The pattern 'true' can never match the type 'false' cerl_inline.erl:2355: The pattern 'true' can never match the type 'false' cerl_inline.erl:238: The pattern 'true' can never match the type 'false' cerl_inline.erl:2436: Function filename/1 will never be called +cerl_inline.erl:244: Function counter_stats/0 will never be called cerl_inline.erl:2700: The pattern 'true' can never match the type 'false' cerl_inline.erl:2730: The pattern <{F, L, D}, Vs> can never match the type <[1..255,...],[any()]> cerl_inline.erl:2738: The pattern <{F, L, D}, Vs> can never match the type <[1..255,...],[any()]> diff --git a/lib/dialyzer/test/r9c_SUITE_data/results/inets b/lib/dialyzer/test/r9c_SUITE_data/results/inets index 24cb39e52b..773525eb7f 100644 --- a/lib/dialyzer/test/r9c_SUITE_data/results/inets +++ b/lib/dialyzer/test/r9c_SUITE_data/results/inets @@ -8,6 +8,7 @@ http_lib.erl:424: The variable _ can never match since previous clauses complete http_lib.erl:438: The variable _ can never match since previous clauses completely covered the type any() http_lib.erl:99: Function getHeaderValue/2 will never be called httpc_handler.erl:660: Function exit_session_ok/2 has no local return +httpc_handler.erl:676: Function format_time/0 will never be called httpc_manager.erl:145: The pattern {ErrorReply, State2} can never match the type {{'ok',number()},number(),#state{reqid::number()}} httpc_manager.erl:160: The pattern {ErrorReply, State2} can never match the type {{'ok',number()},number(),#state{reqid::number()}} httpc_manager.erl:478: The pattern {'error', Reason} can never match the type 'ok' | {number(),#session{clientclose::boolean(),pipeline::[],quelength::1}} diff --git a/lib/dialyzer/test/small_SUITE_data/results/cerl_hipeify b/lib/dialyzer/test/small_SUITE_data/results/cerl_hipeify index 87bf6f309f..06dc0d63ee 100644 --- a/lib/dialyzer/test/small_SUITE_data/results/cerl_hipeify +++ b/lib/dialyzer/test/small_SUITE_data/results/cerl_hipeify @@ -1,4 +1,4 @@ cerl_hipeify.erl:370: Function will never be called -cerl_hipeify.erl:370: Guard test fun((none()) -> none()) =:= F::{_,_,_} | {_,_,_,_} | {_,_,_,_,_} | {_,_,_,_,_,_} | {_,_,_,_,_,_,_} can never succeed +cerl_hipeify.erl:370: Guard test fun((none()) -> no_return()) =:= F::{_,_,_} | {_,_,_,_} | {_,_,_,_,_} | {_,_,_,_,_,_} | {_,_,_,_,_,_,_} can never succeed cerl_hipeify.erl:641: Function env__new_function_name/2 will never be called diff --git a/lib/dialyzer/test/small_SUITE_data/results/inf_loop2 b/lib/dialyzer/test/small_SUITE_data/results/inf_loop2 index 7e9972ad98..142e4b2c37 100644 --- a/lib/dialyzer/test/small_SUITE_data/results/inf_loop2 +++ b/lib/dialyzer/test/small_SUITE_data/results/inf_loop2 @@ -1,4 +1,4 @@ inf_loop2.erl:18: Function test/0 has no local return inf_loop2.erl:19: The call lists:reverse('gazonk') will never return since it differs in the 1st argument from the success typing arguments: ([any()]) -inf_loop2.erl:22: Function loop/0 has no local return +inf_loop2.erl:22: Function loop/0 will never be called diff --git a/lib/dialyzer/test/small_SUITE_data/results/no_local_return b/lib/dialyzer/test/small_SUITE_data/results/no_local_return new file mode 100644 index 0000000000..6ca1ed51d8 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/results/no_local_return @@ -0,0 +1,3 @@ + +no_local_return.erl:11: Function bar/1 will never be called +no_local_return.erl:8: Function foo/0 will never be called diff --git a/lib/dialyzer/test/small_SUITE_data/src/no_local_return.erl b/lib/dialyzer/test/small_SUITE_data/src/no_local_return.erl new file mode 100644 index 0000000000..4e1a0b015a --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/no_local_return.erl @@ -0,0 +1,12 @@ +-module(no_local_return). + +%% NOTE: No function is exported. Dialyzer produced a bogus +%% 'Function foo/0 has no local return' warning +%% when in fact typer was finding correct return values for both +%% these functions. + +foo() -> + bar(42). + +bar(X) -> + lists:duplicate(X, gazonk). -- cgit v1.2.3 From 1f9f1f5f841853310889d3668141b807b744ece2 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Thu, 1 Mar 2012 10:59:34 +0100 Subject: Fix bug in remote type solving --- .../test/behaviour_SUITE_data/src/custom_sup.erl | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/dialyzer/test/behaviour_SUITE_data/src/custom_sup.erl (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/behaviour_SUITE_data/src/custom_sup.erl b/lib/dialyzer/test/behaviour_SUITE_data/src/custom_sup.erl new file mode 100644 index 0000000000..8ec84d798f --- /dev/null +++ b/lib/dialyzer/test/behaviour_SUITE_data/src/custom_sup.erl @@ -0,0 +1,37 @@ +%%% Dialyzer was giving a warning with this input because of a bug in the +%%% substitution of remote types in specs. Remote types in the first element of +%%% a tuple would not update the tuple's tag set and we could end up with a +%%% non-normalized representation. +%%% +%%% Reported by Damian DobroczyƄski on 29/02/2012 + +-module(custom_sup). + +-behavior(supervisor). + +-export([init/1]). + +-spec init(atom()) -> + {ok, {{supervisor:strategy(), non_neg_integer(), non_neg_integer()}, + [supervisor:child_spec()]}} | ignore. + +init(StorageName) -> + Strategy = {one_for_all, 100, 1}, + %% get application-wide storage parameters + case application:get_env(storage) of + undefined -> + ignore; + {ok, Storage} -> + BackendId = proplists:get_value(backend, Storage), + BackendArgs = proplists:get_value(args, Storage), + if + (BackendId =:= undefined) orelse (BackendArgs =:= undefined) -> + ignore; + true -> + {ok, {Strategy, + [{id1, {a_module, start_link, []}, + permanent, 5000, worker, [a_module]}, + {id2, {another_module, start_link, []}, + permanent, 5000, worker, [another_module]}]}} + end + end. -- cgit v1.2.3 From 3cc9dc31c5935168051286d524618b2b64795498 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 13 Mar 2012 17:27:50 +0100 Subject: Ensure that -on_load functions are not reported as unused --- lib/dialyzer/test/small_SUITE_data/src/on_load.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/dialyzer/test/small_SUITE_data/src/on_load.erl (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/small_SUITE_data/src/on_load.erl b/lib/dialyzer/test/small_SUITE_data/src/on_load.erl new file mode 100644 index 0000000000..16533a9caa --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/on_load.erl @@ -0,0 +1,11 @@ +%%% This is to ensure that "on_load" functions are never reported as unused. + +-module(on_load). + +-export([foo/0]). + +-on_load(bar/0). + +foo() -> ok. + +bar() -> ok. -- cgit v1.2.3