Skip to content

Commit

Permalink
Add more new test cases for module inclusion errors
Browse files Browse the repository at this point in the history
These test cases will also have improved error messages in the next
non-test commit.  They come from the work done to address reviewer
comments for ocaml#10407.
  • Loading branch information
antalsz committed Jun 4, 2021
1 parent e9a9748 commit 633caea
Show file tree
Hide file tree
Showing 4 changed files with 426 additions and 0 deletions.
36 changes: 36 additions & 0 deletions testsuite/tests/typing-gadts/return_type.ml
@@ -0,0 +1,36 @@
(* TEST
* expect
*)

type i = int

type 'a t = T : i
[%%expect{|
type i = int
Line 3, characters 16-17:
3 | type 'a t = T : i
^
Error: Constraints are not satisfied in this type.
Type i should be an instance of 'a t
|}]

type 'a t = T : i t
type 'a s = 'a t = T : i t
[%%expect{|
type 'a t = T : i t
Line 2, characters 23-26:
2 | type 'a s = 'a t = T : i t
^^^
Error: Constraints are not satisfied in this type.
Type i t should be an instance of 'a s
|}]

type 'a t = T : i s
and 'a s = 'a t
[%%expect{|
Line 1, characters 16-19:
1 | type 'a t = T : i s
^^^
Error: Constraints are not satisfied in this type.
Type i s should be an instance of 'a t
|}]
Expand Up @@ -42,3 +42,20 @@ Error: Signature mismatch:
type t += A
A private type would be revealed.
|}];;

module M2 : sig type t += A end = struct type t += private A | B end;;
[%%expect{|
Line 1, characters 34-68:
1 | module M2 : sig type t += A end = struct type t += private A | B end;;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
sig type t += private A | B end
is not included in
sig type t += A end
Extension declarations do not match:
type t += private A
is not included in
type t += A
A private type would be revealed.
|}];;

0 comments on commit 633caea

Please sign in to comment.