summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-gadts/pr7390.ml
blob: 4c7b65b32893d42c6962d762db01dd73987651a2 (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
(* TEST
   * expect
*)

type empty = Empty and filled = Filled
type ('a,'fout,'fin) opt =
  | N : ('a, 'f, 'f) opt
  | Y : 'a -> ('a, filled, empty) opt
type 'fill either =
  | Either : (string, 'fill, 'f) opt * (int, 'f, empty) opt -> 'fill either;;
[%%expect{|
type empty = Empty
and filled = Filled
type ('a, 'fout, 'fin) opt =
    N : ('a, 'f, 'f) opt
  | Y : 'a -> ('a, filled, empty) opt
type 'fill either =
    Either : (string, 'fill, 'f) opt * (int, 'f, empty) opt -> 'fill either
|}]

let f (* : filled either -> string *) =
  fun (Either (Y a, N)) -> a;;
[%%expect{|
Line 2, characters 2-28:
2 |   fun (Either (Y a, N)) -> a;;
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
Either (N, Y _)
val f : filled either -> string = <fun>
|}]