summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-modules/extension_constructors_errors_test.ml
blob: b273c9d0e8bc7e4242f6d9bbe6fe18d9160228cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(* TEST
 expect;
*)

type t = ..;;

module M : sig type t += E | F end = struct type t += E | F of int end;;
[%%expect{|
type t = ..
Line 3, characters 37-70:
3 | module M : sig type t += E | F end = struct type t += E | F of int end;;
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
       Modules do not match:
         sig type t += E | F of int  end
       is not included in
         sig type t += E | F  end
       Extension declarations do not match:
         type t += F of int
       is not included in
         type t += F
       Constructors do not match:
         F of int
       is not the same as:
         F
       They have different arities.
|}];;

module M1 : sig type t += A end = struct type t += private A end;;
[%%expect{|
Line 1, characters 34-64:
1 | module M1 : sig type t += A end = struct type t += private A end;;
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
       Modules do not match:
         sig type t += private A 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
       Private extension constructor(s) 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
       Private extension constructor(s) would be revealed.
|}];;