summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-misc/typetexp_errors.ml
diff options
context:
space:
mode:
authorNick Barnes <nick@tarides.com>2023-05-02 21:16:12 +0100
committerNick Barnes <nick@tarides.com>2023-05-02 21:16:12 +0100
commitd3a5c923939a1fc03cc14c005d61210d8c3bd546 (patch)
tree5459de2b7b6cbaa1167d18224f1ea5d256e2f3f7 /testsuite/tests/typing-misc/typetexp_errors.ml
parentad111da274b58d82249f92b8c79ee252bf25525b (diff)
parent23dab79a4e42856aa33816b9c79c3d4d79959cb9 (diff)
downloadocaml-d3a5c923939a1fc03cc14c005d61210d8c3bd546.tar.gz
Merge branch 'trunk' into nick-get-copy
Diffstat (limited to 'testsuite/tests/typing-misc/typetexp_errors.ml')
-rw-r--r--testsuite/tests/typing-misc/typetexp_errors.ml25
1 files changed, 24 insertions, 1 deletions
diff --git a/testsuite/tests/typing-misc/typetexp_errors.ml b/testsuite/tests/typing-misc/typetexp_errors.ml
index 986d858586..4f71bd478b 100644
--- a/testsuite/tests/typing-misc/typetexp_errors.ml
+++ b/testsuite/tests/typing-misc/typetexp_errors.ml
@@ -1,5 +1,5 @@
(* TEST
- * expect
+ expect;
*)
type ('a,'at,'any,'en) t = A of 'an
@@ -31,3 +31,26 @@ Line 1, characters 6-9:
^^^
Error: The type variable name '_a is not allowed in programs
|}]
+
+(* The next two hit the unification error case at the end of
+ Typetexp.globalize_used_variables. *)
+let f (x: int as 'a) (y: float as 'a) = (x,y)
+[%%expect{|
+Line 1, characters 25-36:
+1 | let f (x: int as 'a) (y: float as 'a) = (x,y)
+ ^^^^^^^^^^^
+Error: This type float should be an instance of type int
+|}]
+
+type 'a t1 = 'a constraint 'a = 'b list
+type 'a t2 = 'a constraint 'a = 'b option
+
+let f (x : 'a t1) = (assert false : 'a t2)
+[%%expect{|
+type 'a t1 = 'a constraint 'a = 'b list
+type 'a t2 = 'a constraint 'a = 'b option
+Line 4, characters 36-38:
+4 | let f (x : 'a t1) = (assert false : 'a t2)
+ ^^
+Error: This type 'a option should be an instance of type 'b list
+|}]