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

type +'a n = private int
type nil = private Nil_type
type (_,_) elt =
  | Elt_fine: 'nat n -> ('l,'nat * 'l) elt
  | Elt: 'nat n -> ('l,'nat -> 'l) elt
type _ t = Nil : nil t | Cons : ('x, 'fx) elt * 'x t -> 'fx t;;

let undetected: ('a -> 'b -> nil) t -> 'a n -> 'b n -> unit = fun sh i j ->
  let Cons(Elt dim, _) = sh in ()
;;

[%%expect{|
type +'a n = private int
type nil = private Nil_type
type (_, _) elt =
    Elt_fine : 'nat n -> ('l, 'nat * 'l) elt
  | Elt : 'nat n -> ('l, 'nat -> 'l) elt
type _ t = Nil : nil t | Cons : ('x, 'fx) elt * 'x t -> 'fx t
Line 9, characters 11-18:
9 |   let Cons(Elt dim, _) = sh in ()
               ^^^^^^^
Error: This pattern matches values of type ($Cons_'x, 'a -> $Cons_'x) elt
       but a pattern was expected which matches values of type
         ($Cons_'x, 'a -> $'b -> nil) elt
       The type constructor $'b would escape its scope
|}];;