From 40a3cb7a4657175e5f385d326a63ef012f51585d Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 15 Feb 2018 16:30:12 +0100 Subject: dialyzer: Correct a parameterized opaque types bug See also https://bugs.erlang.org/browse/ERL-565. To avoid loops, erl_types:t_is_subtype checks for equality using unopaqued types, but in (at least) one case something is lost: This fix makes sure that when forwarding arguments in dataflow, types with different parameters but equal when unopaqued are considered different. For example, dict:dict(0, {}) and dict:dict(0, []) are equal when unopaqued (due to how dict(_, _) is declared in module dict), but should be considered different when forwarding args. --- lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same.erl | 15 +++++++++++++++ .../test/opaque_SUITE_data/src/para_bug/same_type.erl | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same.erl create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same_type.erl (limited to 'lib/dialyzer/test') diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same.erl b/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same.erl new file mode 100644 index 0000000000..44149f4199 --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same.erl @@ -0,0 +1,15 @@ +-module(same). + +-export([baz/1]). + +-record(bar, { + a :: same_type:st(integer()), + b :: same_type:st(atom()) + }). + +baz(Bar) -> + _ = wrap_find(0, Bar#bar.a), + wrap_find(0, Bar#bar.b). + +wrap_find(K, D) -> + same_type:t(K, D). diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same_type.erl b/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same_type.erl new file mode 100644 index 0000000000..855a5d30be --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/para_bug/same_type.erl @@ -0,0 +1,13 @@ +-module(same_type). + +-export([t/2]). + +-export_type([st/1]). + +%% When unopaqued all specializations of st/1 are equal. +-opaque st(_A) :: {st, tuple()}. + +-spec t(_, st(_)) -> _. + +t(K, V) -> + {K, V}. -- cgit v1.2.3