summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-gadts/pr5989.ml
blob: a23ade092607fe9263f3c868263e69e93247261a (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
62
63
64
65
66
67
(* TEST
 expect;
*)

type (_, _) t =
    Any : ('a, 'b) t
  | Eq : ('a, 'a) t
;;

module M :
sig
  type s = private [> `A]
  val eq : (s, [`A | `B]) t
end =
struct
  type s = [`A | `B]
  let eq = Eq
end;;

let f : (M.s, [`A | `B]) t -> string = function
  | Any -> "Any"
;;

let () = print_endline (f M.eq) ;;
[%%expect{|
type (_, _) t = Any : ('a, 'b) t | Eq : ('a, 'a) t
module M : sig type s = private [> `A ] val eq : (s, [ `A | `B ]) t end
Lines 16-17, characters 39-16:
16 | .......................................function
17 |   | Any -> "Any"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
Eq

val f : (M.s, [ `A | `B ]) t -> string = <fun>
Exception: Match_failure ("", 16, 39).
|}];;

module N :
sig
  type s = private < a : int; .. >
  val eq : (s, <a : int; b : bool>) t
end =
struct
  type s = <a : int; b : bool>
  let eq = Eq
end
;;

let f : (N.s, <a : int; b : bool>) t -> string = function
  | Any -> "Any"
;;
[%%expect{|
module N :
  sig
    type s = private < a : int; .. >
    val eq : (s, < a : int; b : bool >) t
  end
Lines 12-13, characters 49-16:
12 | .................................................function
13 |   | Any -> "Any"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
Eq

val f : (N.s, < a : int; b : bool >) t -> string = <fun>
|}];;