This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,15 @@
module To_before_503 =
Ppxlib_ast.Convert (Ppxlib_ast.Js) (Ppxlib_ast__.Versions.OCaml_502)
module From_before_503 =
Ppxlib_ast.Convert (Ppxlib_ast__.Versions.OCaml_502) (Ppxlib_ast.Js)
let impl _ctxt str =
(* This manual migration is here to ensure the test still works even once our
internal AST has been bumped past 5.3 *)
let before_503_ast = To_before_503.copy_structure str in
let roundtrip = From_before_503.copy_structure before_503_ast in
roundtrip
let () = Ppxlib.Driver.V2.register_transformation ~impl "503-downward-roundtrip"
let () = Ppxlib.Driver.standalone ()

View file

@ -0,0 +1,10 @@
(executable
(name driver)
(enabled_if
(>= %{ocaml_version} "5.3"))
(libraries ppxlib ocaml-compiler-libs.common compiler-libs.common))
(cram
(enabled_if
(>= %{ocaml_version} "5.3"))
(deps driver.exe))

View file

@ -0,0 +1,24 @@
We should be able to migrate the effect syntax downward and back. This allows users
to run ppx-es on 5.3 on source files that use the effect syntax until we update our
internal AST to fully support it.
We have a custom driver that will force migration of the AST down to 5.2 and back to
the compiler's version and print it as source code using the compiler's printer,
regardless of ppxlib's internal AST version.
If we run the driver on the following source file:
$ cat > test.ml << EOF
> let handler f =
> match f () with
> | x -> x
> | effect Random_bits, k -> Effect.Deep.continue k (Random.bits ())
> EOF
it should successfully roundtrip to 5.2 and print the source code unchanged:
$ ./driver.exe test.ml --use-compiler-pp
let handler f =
match f () with
| x -> x
| effect Random_bits, k -> Effect.Deep.continue k (Random.bits ())