aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-01-10 10:31:29 +0100
committerHans Bolinder <[email protected]>2017-01-10 10:31:29 +0100
commit99ed930f507868906953c6169a58c03df3e10901 (patch)
tree3b7da9064e9ae4d10f255bf6a826d075e1da4fa2 /lib/dialyzer
parent61547cab473396ac5ec03b491fd74c8fe7e7ce54 (diff)
parent6d2380326a67a00eeae31689c00936da6f3526d2 (diff)
downloadotp-99ed930f507868906953c6169a58c03df3e10901.tar.gz
otp-99ed930f507868906953c6169a58c03df3e10901.tar.bz2
otp-99ed930f507868906953c6169a58c03df3e10901.zip
Merge branch 'hasse/stdlib/char_as_integer/ERL-313/OTP-14103' into maint
* hasse/stdlib/char_as_integer/ERL-313/OTP-14103: stdlib: Allow characters in types and constant patterns
Diffstat (limited to 'lib/dialyzer')
-rw-r--r--lib/dialyzer/test/small_SUITE_data/results/chars4
-rw-r--r--lib/dialyzer/test/small_SUITE_data/src/chars.erl32
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/results/chars b/lib/dialyzer/test/small_SUITE_data/results/chars
new file mode 100644
index 0000000000..2c1f8f8d17
--- /dev/null
+++ b/lib/dialyzer/test/small_SUITE_data/results/chars
@@ -0,0 +1,4 @@
+
+chars.erl:29: Invalid type specification for function chars:f/1. The success typing is (#{'b':=50}) -> 'ok'
+chars.erl:32: Function t1/0 has no local return
+chars.erl:32: The call chars:f(#{'b':=50}) breaks the contract (#{'a':=49,'b'=>50,'c'=>51}) -> 'ok'
diff --git a/lib/dialyzer/test/small_SUITE_data/src/chars.erl b/lib/dialyzer/test/small_SUITE_data/src/chars.erl
new file mode 100644
index 0000000000..1e9c8ab6b9
--- /dev/null
+++ b/lib/dialyzer/test/small_SUITE_data/src/chars.erl
@@ -0,0 +1,32 @@
+-module(chars).
+
+%% ERL-313
+
+-export([t/0]).
+-export([t1/0]).
+
+-record(r, {f :: $A .. $Z}).
+
+-type cs() :: $A..$Z | $a .. $z | $/.
+
+-spec t() -> $0-$0..$9-$0| $?.
+
+t() ->
+ c(#r{f = $z - 3}),
+ c($z - 3),
+ c($B).
+
+-spec c(cs()) -> $3-$0..$9-$0.
+
+c($A + 1) -> 2;
+c(C) ->
+ case C of
+ $z - 3 -> 3;
+ #r{f = $z - 3} -> 7
+ end.
+
+%% Display contract with character in warning:
+-spec f(#{a := $1, b => $2, c => $3}) -> ok. % invalid type spec
+f(_) -> ok.
+
+t1() -> f(#{b => $2}). % breaks the contract