From 0d12ca4bb9fc85e9db980f1f4f990a7c81c5a7a4 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 28 Feb 2017 13:26:38 +0100 Subject: dialyzer: Fix a weird warning --- lib/dialyzer/test/opaque_SUITE_data/results/weird | 3 +++ .../opaque_SUITE_data/src/weird/weird_warning3.erl | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/weird/weird_warning3.erl (limited to 'lib/dialyzer/test/opaque_SUITE_data') diff --git a/lib/dialyzer/test/opaque_SUITE_data/results/weird b/lib/dialyzer/test/opaque_SUITE_data/results/weird index cffba85b9f..df69c9b6f2 100644 --- a/lib/dialyzer/test/opaque_SUITE_data/results/weird +++ b/lib/dialyzer/test/opaque_SUITE_data/results/weird @@ -1,3 +1,6 @@ weird_warning1.erl:15: The attempt to match a term of type #b{q::queue:queue(_)} against the pattern {'a', Dict} breaks the opacity of queue:queue(_) weird_warning2.erl:13: The attempt to match a term of type <#a{d::dict:dict(_,_)},'my_key','my_value'> against the pattern <{'b', Queue}, Key, Value> breaks the opacity of dict:dict(_,_) +weird_warning3.erl:14: The call weird_warning3:add_element(#a{d::queue:queue(_)},'my_key','my_value') does not have a term of type #a{d::dict:dict(_,_)} | #b{q::queue:queue(_)} (with opaque subterms) as 1st argument +weird_warning3.erl:16: The attempt to match a term of type #a{d::queue:queue(_)} against the pattern {'a', Dict} breaks the opacity of queue:queue(_) +weird_warning3.erl:18: Matching of pattern {'b', Queue} tagged with a record name violates the declared type of #a{d::queue:queue(_)} diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/weird/weird_warning3.erl b/lib/dialyzer/test/opaque_SUITE_data/src/weird/weird_warning3.erl new file mode 100644 index 0000000000..b70ca645cb --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/weird/weird_warning3.erl @@ -0,0 +1,19 @@ +-module(weird_warning3). +-export([public_func/0]). + +-record(a, { + d = dict:new() :: dict:dict() + }). + +-record(b, { + q = queue:new() :: queue:queue() + }). + +public_func() -> + %% Notice that t_to_string() will create "#a{d::queue:queue(_)}". + add_element({a, queue:new()}, my_key, my_value). + +add_element(#a{d = Dict}, Key, Value) -> + dict:store(Key, Value, Dict); +add_element(#b{q = Queue}, Key, Value) -> + queue:in({Key, Value}, Queue). -- cgit v1.2.3