ocaml-ppx / ocaml-migrate-parsetree

DEPRECATED. See https://ocaml.org/changelog/2023-10-23-omp-deprecation. Convert OCaml parsetrees between different major versions
Other
87 stars 43 forks source link

Fix migration between 4.14 and 5.0 #124

Open laaksonel opened 1 year ago

laaksonel commented 1 year ago

When compiling the following code with OCaml 5 and ocaml-migrate-parsetree 2.4.0

open Migrate_parsetree

let copy_structure str =
  str
  |> Migrate_406_407.copy_structure
  |> Migrate_407_408.copy_structure
  |> Migrate_408_409.copy_structure
  |> Migrate_409_410.copy_structure
  |> Migrate_410_411.copy_structure
  |> Migrate_411_412.copy_structure
  |> Migrate_412_413.copy_structure
  |> Migrate_413_414.copy_structure
  |> Migrate_414_500.copy_structure

let convert (str : Ast_406.Parsetree.structure) : Parsetree.structure =
  copy_structure str

The compilation fails

File "src/main.ml", line 16, characters 2-20:
16 |   copy_structure str
       ^^^^^^^^^^^^^^^^^^
Error: This expression has type
         Migrate_parsetree__.Ast_500.Parsetree.structure =
           Ast_500.Parsetree.structure_item list
       but an expression was expected of type
         Parsetree.structure = Compiler_libs.Parsetree.structure_item list
       Type Ast_500.Parsetree.structure_item is not compatible with type
         Compiler_libs.Parsetree.structure_item

It seems bare identity functions are not enough, so I generated the full-blown migration files. With these files, the compilation passes.