New error using ocaml 5.5.0

I have an error when I compile this code with the new release of Ocaml 5.5.0:

type leaf
(** Fantom type for typing the tree *)

type node
(** Fantom type for typing the tree *)

type ('a, 'v) branch =
  | Leaf : (leaf, 'v) branch
  | Node : (_, 'v) branch * (unit * 'v) * (_, 'v) branch -> (node, 'v) branch

let rec splay : (node, 'any) branch -> unit =
 fun t ->
  let (Node (l, y, r)) = t in
  ignore (l, y, r)

File “test.ml”, lines 13-14, characters 2-18:
13 | ..let (Node (l, y, r)) = t in
14 | ignore (l, y, r)
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched: Leaf

This code was compiling fine in 5.4.0

I do not see here how this branch could match, because the signature of the function prevent the case of the Leaf constructor. Is this because the new compiler is more strict ?

As described in the warning in the release highlights, the correct way to define a type-level tag is

type leaf = private [ `Leaf ]
(** Fantom type for typing the tree *)

type node = private [ `Node]
(** Fantom type for typing the tree *)

otherwise the type checker cannot prove in general that the two types are different.
Consider for instance,

module M: sig
   type leaf
   type node
   type _ t = A: leaf t | B: node t
   val a: node t
end = struct
  type leaf
  type node = leaf
   type _ t = A: leaf t | B: node t
   let a = A
end

let partial: M.(node t) -> unit = function
| B -> ()

let fail = partial M.a

Your version was relying on the special rule for abstract types defined in the current module that has been removed in OCaml 5.5 because it was very brittle and anti-modular.

Thank you, I had read the list of changes but didn’t saw it applies in this case. It make completely sense !