I’m trying to use PPX rewriters, e.g., ppx_sexp_conv, with 5.1.1+effect-syntax variant.
I believe I’ve successfully adapted ppxlib to support 5.1.1+effect-syntax (it compiles).
However, when I pin ppxlib to my adaptation and install ppx_sexp_conv from opam, it gets installed smoothly, but when I dune build in my repo, I get this
37 | | effect Rd_pt, k -> fun ~ptph -> continue k (fst ptph) ~ptph
^^^^^
Error: migration error: effect pattern is not supported before OCaml 5.1.1+effect-syntax
which is an error I added in astlib/migrate_501_500.ml.
This happens when trying to migrate Ppat_effect into OCaml 5.0 Parsetree as it does not have a corresponding construct.
I guess it has to do with migrating the Parsetree version back and forth, but I’m not really sure how to solve this issue.
Moreover, I’m puzzled why it would even use migrate_501_500 as I’m using an OCaml 5.1.1 compiler and ppx_sexp_conv requires "ocaml" {>= "5.1.0"}.
While I tried to modify Js to use Versions.OCaml_501(here), I keep getting the following error when I run dune build --verbose with backtrace enabled (Printexc.record_backtrace true):
File "src/dune", lines 27-31, characters 0-143:
27 | (rule
28 | (targets ast_pattern_generated.ml)
29 | (deps gen/gen_ast_pattern.exe)
30 | (action
31 | (run ./gen/gen_ast_pattern.exe %{lib:ppxlib.ast:ast.ml})))
Command [5] exited with code 2:
$ (cd _build/default/src && gen/gen_ast_pattern.exe ../../install/default/lib/ppxlib/ast/ast.ml)
Raised at Parse.wrap in file "parsing/parse.ml", line 68, characters 6-49
Called from Dune__exe__Import.Loc.lident in file "src/gen/import.ml", line 15, characters 20-39
Called from Dune__exe__Import.evar in file "src/gen/import.ml", line 22, characters 23-37
Called from Dune__exe__Gen_ast_pattern.apply_parsers.(fun) in file "src/gen/gen_ast_pattern.ml", line 15, characters 58-69
Called from Stdlib__List.fold_left2 in file "list.ml", line 161, characters 37-51
Called from Dune__exe__Gen_ast_pattern.gen_combinator_for_record in file "src/gen/gen_ast_pattern.ml", line 86, characters 4-149
Called from Dune__exe__Gen_ast_pattern.gen_td in file "src/gen/gen_ast_pattern.ml", line 175, characters 22-75
Called from Stdlib__List.rev_map.rmap_f in file "list.ml", line 105, characters 22-25
Called from Stdppx.List.map in file "stdppx/stdppx.ml", line 186, characters 26-43
Called from Dune__exe__Gen_ast_pattern.generate in file "src/gen/gen_ast_pattern.ml", line 223, characters 4-279
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Dune__exe__Gen_ast_pattern in file "src/gen/gen_ast_pattern.ml", line 246, characters 6-43
File "_none_", line 1, characters 0-10:
Error: Syntax error
The version I pushed to my GitHub repo has a non-exhaustive pprintast.ml (e.g., it doesn’t handle effect syntax or Pmod_apply_unit). However, fixing it results in the same error.
After spending a dozen hours debugging, I’m currently resorting to writing my own sexp converters. I’m documenting what I’ve been through in case someone with more expertise has some pointers to solve this issue.