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


type (_, _) eq = Refl : ('a, 'a) eq;;

let foo (type a) (x : (a, int) eq) (a : a) p =
  let module M = struct type t = a let x : t = a end in
  if p then a else M.x;;
[%%expect{|
type (_, _) eq = Refl : ('a, 'a) eq
val foo : ('a, int) eq -> 'a -> bool -> 'a = <fun>
|}]

let foo (type a) (x : (a, int) eq) (a : a) p =
  let module M = struct type t = a let x : t = a end in
  let Refl = x in
  if p then a else M.x;;
[%%expect{|
val foo : ('a, int) eq -> 'a -> bool -> 'a = <fun>
|}]

let foo (type a) (x : (a, int) eq) (a : a) p =
  let module M = struct type 'a t = a let x : 'a t = a end in
  let Refl = x in
  if p then a else M.x;;
[%%expect{|
val foo : ('a, int) eq -> 'a -> bool -> 'a = <fun>
|}]

let foo (type a) (x : (a, int) eq) (a : a) p =
  let module M = struct type 'a t = 'a let x : a t = a end in
  let Refl = x in
  if p then a else M.x;;
[%%expect{|
val foo : ('a, int) eq -> 'a -> bool -> 'a = <fun>
|}]

type ('a,'b) fst = 'a

let foo4 (type a) (x : (a, int) eq) (a : a) p =
  let module M : sig type t = (a,bool) fst val x : t end =
    struct type t = (a,bool) fst let x = a end in
  let Refl = x in
  if p then a else M.x;;
[%%expect{|
type ('a, 'b) fst = 'a
val foo4 : ('a, int) eq -> 'a -> bool -> 'a = <fun>
|}]