janestreet / sexplib

Automated S-expression conversion
MIT License
147 stars 27 forks source link

Compilation errors using Sexplib v0.15.0 with OCaml 4.13.1 #43

Closed dedbox closed 2 years ago

dedbox commented 2 years ago

Hello, I'm working on the Hazel structure editor, a js_of_ocaml / incr_dom app written mostly in ReasonML, and am upgrading OCaml from 4.12 to 4.13.1 (hazelgrove/hazel#597). The opam process went smoothly enough, but compilation with sexplib (and sexplib0 and ppx_sexp_conv) at v0.15.0 fails:

$ make
dune build @src/fmt --auto-promote || true
dune build src --profile dev
File "src/hazelcore/UHTyp.re", line 5, characters 0-14:
5 | type t = opseq
    ^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
File "src/hazelcore/ZTyp.re", line 2, characters 0-15:
2 | type t = zopseq
    ^^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
File "src/hazelcore/UHPat.re", line 9, characters 0-14:
9 | type t = opseq
    ^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
File "src/hazelcore/UHExp.re", line 7, characters 0-14:
7 | type t = block
    ^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
make: *** [Makefile:14: dev] Error 1

At the first source location:

[@deriving sexp]
type t = opseq
and opseq = OpSeq.t(operand, operator)
and operand =
  | Hole
  | Unit
  | Int
  | Float
  | Bool
  | Parenthesized(t)
  | List(t);

The rest correspond to similar forms: [@deriving sexp] type t = u and u = ... where u is an identifier.

Since there are no let recs in or around the referenced locations, I'm guessing there's an issue with sexplib or ppx_sexp_conv or something in between.

Indeed, downgrading sexplib or sexplib0 to v0.14.0, or ppx_sexp_conv to v0.14.3, makes the errors go away, but downgrading any one also downgrades the others, so I'm not sure where to look next.

Upgrading sexplib0 and ppx_sexp_conv to v0.15.1 (with sexplib at v0.15.0) has no effect - the compiler produces the same errors.

ceastlund commented 2 years ago

This appears to be more of a ppx_sexp_conv error than a sexplib error, since it's being reported in terms of invalid expression syntax in let rec expressions. And it's not clear to me if the problem is ppx_sexp_conv generating bad OCaml code, or ReasonML somehow not accepting its output. If you can report this issue on the ppx_sexp_conv repository, and either reproduce it in OCaml or at least produce the output of the ppx, that would help a lot, thanks.