aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-02-28 13:26:38 +0100
committerHans Bolinder <[email protected]>2017-02-28 14:37:15 +0100
commit0d12ca4bb9fc85e9db980f1f4f990a7c81c5a7a4 (patch)
treedbad9f8dae2848924a6dae32a12e26e65b1643da /lib/dialyzer/test
parent4827fa95257c1d68bcdcac2c6d4a35cd8b56d8cd (diff)
downloadotp-0d12ca4bb9fc85e9db980f1f4f990a7c81c5a7a4.tar.gz
otp-0d12ca4bb9fc85e9db980f1f4f990a7c81c5a7a4.tar.bz2
otp-0d12ca4bb9fc85e9db980f1f4f990a7c81c5a7a4.zip
dialyzer: Fix a weird warning
Diffstat (limited to 'lib/dialyzer/test')
-rw-r--r--lib/dialyzer/test/opaque_SUITE_data/results/weird3
-rw-r--r--lib/dialyzer/test/opaque_SUITE_data/src/weird/weird_warning3.erl19
2 files changed, 22 insertions, 0 deletions
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).