janestreet / janestreet/bin_prot

bin_prot 0.16.0 doesn't like trivial cases in mutually recursive type definitions

Open
#32 3 comments 0 reactions 0 assignees View on GitHub
forwarded-to-js-devs
Dominant language
OCaml
Stars
88
Forks
25
PR merge metrics
No merged PRs in 30d

Description

The following snippet fails to compile:

```ocaml
open Bin_prot.Std

type ab =
| A of a
| B of int

and a = ab [@@deriving bin_io]
```

with error message

```
7 | and a = ab [@@deriving bin_io]
^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
```

It builds if we remove `[@@deriving bin_io]` or if we replace `bin_io` with `show`.

Tested with `bin_prot 0.16.0`, can't migrate to `0.17.x` atm because of dependencies that are not compatible with OCaml 5.x.

Contributor guide

Open the contributing guide

Research direction

Reproduce the mutually recursive type definition from the issue with bin_prot 0.16.0 and the bin_io deriver, then trace how this case is handled during compilation. Done means the snippet compiles successfully and the trivial mutually recursive case has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.