diff options
author | Hans Bolinder <[email protected]> | 2014-03-17 09:53:32 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2014-03-21 14:19:15 +0100 |
commit | c777e4096a21f9734a1cec8d723137299b0f9193 (patch) | |
tree | ba035cb658a8e645b0c50aa3016ad8c7ba2ba5b2 /lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl | |
parent | 4d614d868f90cfae31046038e6f178002a13c9ef (diff) | |
download | otp-c777e4096a21f9734a1cec8d723137299b0f9193.tar.gz otp-c777e4096a21f9734a1cec8d723137299b0f9193.tar.bz2 otp-c777e4096a21f9734a1cec8d723137299b0f9193.zip |
dialyzer: generalize guard constraints in a new way
Guard constraints used to be limited to a certain depth, which handled
mutually depending constraints safely, but also sometimes introduced
unnecessary generalizations.
This patch puts no explicit limit upon guard constraints (other than
those that already exist in erl_types), but breaks cycles by replacing
variables with the any() type.
In some cases the old method resulted in more warnings, but since the
limit was quite arbitrary and mutually depending guard constraints are
(very) rare, the new method should been seen as an improvement since
it handles cases that used to make Dialyzer loop or miss warnings.
Diffstat (limited to 'lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl')
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl b/lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl new file mode 100644 index 0000000000..d2f945b284 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/contracts_with_subtypes2.erl @@ -0,0 +1,40 @@ +-module(contracts_with_subtypes2). + +-compile(export_all). + +-behaviour(supervisor). + +-spec t(Arg) -> ok when + Arg :: {a, A}, + A :: {b, B}, + B :: {c, C}, + C :: {d, D}, + D :: {e, E}, + E :: {f, _}. + +t(X) -> + get(X). + +t() -> + t({a, {b, {c, {d, {e, {g, 3}}}}}}). % breaks the contract + +%% This one should possibly result in warnings about unused variables. +-spec l() -> ok when + X :: Y, + Y :: X. + +l() -> + ok. + +%% This is the example from seq12547 (ticket OTP-11798). +%% There used to be a warning. + +-spec init(term()) -> Result when + Result :: {ok, {{supervisor:strategy(), + non_neg_integer(), + pos_integer()}, + [supervisor:child_spec()]}} + | ignore. + +init(_) -> + foo:bar(). |