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

module F(S : sig type 'a t end) = struct
  type _ ab =
      A : int S.t ab
    | B : float S.t ab

  let f : int S.t ab -> float S.t ab -> string =
    fun (l : int S.t ab) (r : float S.t ab) -> match l, r with
    | A, B -> "f A B"
end;;
[%%expect{|
Line _, characters 47-84:
  ...............................................match l, r with
      | A, B -> "f A B"
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(A, A)
module F :
  functor (S : sig type 'a t end) ->
    sig
      type _ ab = A : int S.t ab | B : float S.t ab
      val f : int S.t ab -> float S.t ab -> string
    end
|}];;

module F(S : sig type 'a t end) = struct
  type a = int * int
  type b = int -> int

  type _ ab =
      A : a S.t ab
    | B : b S.t ab

  let f : a S.t ab -> b S.t ab -> string =
    fun l r -> match l, r with
    | A, B -> "f A B"
end;;
[%%expect{|
Line _, characters 15-52:
  ...............match l, r with
      | A, B -> "f A B"
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(A, A)
module F :
  functor (S : sig type 'a t end) ->
    sig
      type a = int * int
      type b = int -> int
      type _ ab = A : a S.t ab | B : b S.t ab
      val f : a S.t ab -> b S.t ab -> string
    end
|}];;