diff options
| author | Florian Angeletti <florian.angeletti@inria.fr> | 2023-04-05 10:20:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-05 10:20:28 +0200 |
| commit | 12f812abcd46a818cd561e686210cec90edf0fec (patch) | |
| tree | 5a5c82d7dfabd7a5548dcbb58fc1312c63b0ffbe | |
| parent | cfeed85883ac8b09f6ef10d15690c5a00f1eb3fc (diff) | |
| parent | 56ded09d5829e51a89395f5c64aa73b3f690a0da (diff) | |
| download | ocaml-12f812abcd46a818cd561e686210cec90edf0fec.tar.gz | |
Merge pull request #12155 from ccasin/reach-unification-failure
Add test case demonstrating that an error in Typetexp can be reached.
| -rw-r--r-- | testsuite/tests/typing-misc/typetexp_errors.ml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/typing-misc/typetexp_errors.ml b/testsuite/tests/typing-misc/typetexp_errors.ml index 986d858586..7dc03e90ac 100644 --- a/testsuite/tests/typing-misc/typetexp_errors.ml +++ b/testsuite/tests/typing-misc/typetexp_errors.ml @@ -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 +|}] |
