summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-gadts/pr7378.ml
blob: 1499ac5960da424e5ce92025f4825eae06f028d4 (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
(* TEST
 expect;
*)

module X = struct
  type t =
    | A : 'a * 'b * ('a -> unit) -> t
end;;
[%%expect{|
module X : sig type t = A : 'a * 'b * ('a -> unit) -> t end
|}]

module Y = struct
  type t = X.t =
    | A : 'a * 'b * ('b -> unit) -> t
end;; (* should fail *)
[%%expect{|
Lines 2-3, characters 2-37:
2 | ..type t = X.t =
3 |     | A : 'a * 'b * ('b -> unit) -> t
Error: This variant or record definition does not match that of type X.t
       Constructors do not match:
         A : 'a * 'b * ('a -> unit) -> X.t
       is not the same as:
         A : 'a * 'b * ('b -> unit) -> X.t
       The type 'a -> unit is not equal to the type 'b -> unit
       Type 'a is not equal to type 'b
|}]

(* would segfault
let () =
  match Y.A (1, "", print_string) with
  | X.A (x, y, f) -> f x
*)