# New error using ocaml 5.5.0

**URL:** <https://discuss.ocaml.org/t/new-error-using-ocaml-5-5-0/18284>\
**Category:** Learning\
**Created:** [June 23, 2026, 5:03pm UTC](https://discuss.ocaml.org/t/new-error-using-ocaml-5-5-0/18284 "2026-06-23T17:03:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chimrod](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chimrod/32/6042_2.png) [@Chimrod](https://discuss.ocaml.org/u/Chimrod)\
**Post date:** [June 23, 2026, 5:03pm UTC](https://discuss.ocaml.org/t/new-error-using-ocaml-5-5-0/18284/1 "2026-06-23T17:03:32Z")

</div>

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

```ocaml
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 ?

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [June 23, 2026, 6:33pm UTC](https://discuss.ocaml.org/t/new-error-using-ocaml-5-5-0/18284/2 "2026-06-23T18:33:51Z")

</div>

> [@Chimrod](#):
>
> ```auto
> type leaf
> (** Fantom type for typing the tree *)
> 
> type node
> (** Fantom type for typing the tree *)
> 
> ```

As described in [the warning in the release highlights](https://discuss.ocaml.org/t/ocaml-5-5-0-released/18265#p-76945-warning-abstract-types-in-the-current-module-7), the correct way to define a type-level tag is

```ocaml
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,

```ocaml
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.

---

<div class="post-metadata">

**Author:** ![Chimrod](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chimrod/32/6042_2.png) [@Chimrod](https://discuss.ocaml.org/u/Chimrod)\
**Post date:** [June 23, 2026, 7:12pm UTC](https://discuss.ocaml.org/t/new-error-using-ocaml-5-5-0/18284/3 "2026-06-23T19:12:52Z")

</div>

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