I’m new to OCaml but pretty solid with Haskell, and so to learn some OCaml, I’m trying to write a front end for a J-like language, loosely following this tutorial. I’ve run into an error I can’t diagnose.
I’m trying to serialize the front end with protobufs into an intermediate representation; the grammar looks like
type adverb =
| TAdverb of string [@key 1]
[@@deriving protobuf {protoc= "../../frontend_ir.proto"}]
type conjunction =
| TConjunction of string [@key 1]
[@@deriving protobuf {protoc= "../../frontend_ir.proto"}]
type nounexpr =
| TId of string [@key 1]
| TIArray of int list [@key 2]
| TFArray of float list [@key 3]
[@@deriving protobuf {protoc= "../../frontend_ir.proto"}]
type verb =
| TSimpleVerb of string [@key 1]
| TModVerb of verb * adverb [@key 2]
| THook of verb * verb [@key 3]
| TFork of verb * verb * verb [@key 4]
| TVerbalNounSuffix of nounexpr * conjunction * verb [@key 5]
| TVerbalNounPrefix of verb * conjunction * nounexpr [@key 6]
| TConj of verb * conjunction * verb [@key 7]
[@@deriving protobuf {protoc= "../../frontend_ir.proto"}]
type expr =
| TAssign of string * expr * expr [@key 1]
| TLiteralNoun of nounexpr [@key 2]
| TMonadic of verb * expr [@key 3]
| TDyadic of expr * verb * expr [@key 4]
[@@deriving protobuf {protoc= "../../frontend_ir.proto"}]
The accompanying dune
file looks like this:
(library
(name ir_gen)
(libraries core core_unix core_unix.sys_unix core_unix.command_unix fmt ast)
(flags
(:standard -w -39))
(preprocess
(pps ppx_deriving_protobuf bisect_ppx --conditional))
(lint
(pps ppx_js_style -check-doc-comments -annotated-ignores -styler -pretty -dated-deprecation)))
When I do dune build
, I get the following error:
7 | (pps ppx_deriving_protobuf bisect_ppx --conditional))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fatal error: exception File "ppx_deriving_protobuf.cppo.ml", line 1146, characters 28-34: Assertion failed
The only reference to a similar error that I can find is a bug from 7 years ago.
Any advice about how to understand this error better? If I could look at the file ppx_deriving_protobuf.cppo.ml
maybe I could figure out what’s wrong, but I think it’s part of the build and I don’t know how to access it.