From 5c7b96c705b9652a2c82b1efa54a29e191b9d365 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 3 Oct 2026 21:57:13 -0700 Subject: [PATCH] fix: adapt package-constraint migrations to OCaml 5.6 --- src/vendored-omp/src/ast_56.ml | 2 +- .../src/migrate_parsetree_55_56_migrate.ml | 2 +- .../src/migrate_parsetree_56_55_migrate.ml | 2 +- test/lib/dune | 6 +++++ test/lib/packageConstraints.ml | 26 +++++++++++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/lib/packageConstraints.ml diff --git a/src/vendored-omp/src/ast_56.ml b/src/vendored-omp/src/ast_56.ml index 690f5fb2a..2ff7c3a2b 100644 --- a/src/vendored-omp/src/ast_56.ml +++ b/src/vendored-omp/src/ast_56.ml @@ -155,7 +155,7 @@ module Outcometree = struct and out_package (*IF_CURRENT = Outcometree.out_package *) = { opack_path: out_ident; - opack_constraints: (string * out_type) list; + opack_constraints: (string list * out_type) list; } and out_variant (*IF_CURRENT = Outcometree.out_variant *) = diff --git a/src/vendored-omp/src/migrate_parsetree_55_56_migrate.ml b/src/vendored-omp/src/migrate_parsetree_55_56_migrate.ml index 925b5a3f0..c34cbbf9d 100644 --- a/src/vendored-omp/src/migrate_parsetree_55_56_migrate.ml +++ b/src/vendored-omp/src/migrate_parsetree_55_56_migrate.ml @@ -304,7 +304,7 @@ and (copy_out_package : { Ast_56.Outcometree.opack_path = (copy_out_ident opack_path); Ast_56.Outcometree.opack_constraints = - (List.map (fun x -> let (x0, x1) = x in (x0, (copy_out_type x1))) + (List.map (fun (x0, x1) -> (String.split_on_char '.' x0, copy_out_type x1)) opack_constraints) } and (copy_out_variant : diff --git a/src/vendored-omp/src/migrate_parsetree_56_55_migrate.ml b/src/vendored-omp/src/migrate_parsetree_56_55_migrate.ml index 71f9f6b2a..0933dc134 100644 --- a/src/vendored-omp/src/migrate_parsetree_56_55_migrate.ml +++ b/src/vendored-omp/src/migrate_parsetree_56_55_migrate.ml @@ -304,7 +304,7 @@ and (copy_out_package : { Ast_55.Outcometree.opack_path = (copy_out_ident opack_path); Ast_55.Outcometree.opack_constraints = - (List.map (fun x -> let (x0, x1) = x in (x0, (copy_out_type x1))) + (List.map (fun (x0, x1) -> (String.concat "." x0, copy_out_type x1)) opack_constraints) } and (copy_out_variant : diff --git a/test/lib/dune b/test/lib/dune index fdd7049e3..b37687862 100644 --- a/test/lib/dune +++ b/test/lib/dune @@ -15,3 +15,9 @@ (modules fdLeak) (flags :standard -open StdLabels) (libraries reason.refmt-lib)) + +(test + (name packageConstraints) + (modules packageConstraints) + (package reason) + (libraries reason.ocaml-migrate-parsetree)) diff --git a/test/lib/packageConstraints.ml b/test/lib/packageConstraints.ml new file mode 100644 index 000000000..6495451c4 --- /dev/null +++ b/test/lib/packageConstraints.ml @@ -0,0 +1,26 @@ +module Old = Reason_omp.Ast_55.Outcometree +module New = Reason_omp.Ast_56.Outcometree + +let old_package = + Old.Otyp_module + { opack_path = Oide_ident { printed_name = "S" } + ; opack_constraints = + [ "t", Otyp_var (false, "a") + ; "M.t", Otyp_var (false, "b") + ; "M.N.u", Otyp_var (false, "c") + ] + } + +let new_package = + New.Otyp_module + { opack_path = Oide_ident { printed_name = "S" } + ; opack_constraints = + [ [ "t" ], Otyp_var (false, "a") + ; [ "M"; "t" ], Otyp_var (false, "b") + ; [ "M"; "N"; "u" ], Otyp_var (false, "c") + ] + } + +let () = + assert (Reason_omp.Migrate_55_56.copy_out_type old_package = new_package); + assert (Reason_omp.Migrate_56_55.copy_out_type new_package = old_package)