From eede4de38218d19166419b55b99a5dcb53bbadfe Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Fri, 16 Feb 2024 09:18:17 +0100 Subject: [PATCH 1/7] Add test for standalone driver support of old binary ASTs Signed-off-by: Nathan Rebours --- .../standalone-supports-old-binary-ast/dune | 19 ++++++++++++++++++ .../identity_standalone.ml | 1 + .../print_magic_number.ml | 5 +++++ .../test.t/406_binary_ast | Bin 0 -> 460 bytes .../test.t/run.t | 14 +++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 test/driver/standalone-supports-old-binary-ast/dune create mode 100644 test/driver/standalone-supports-old-binary-ast/identity_standalone.ml create mode 100644 test/driver/standalone-supports-old-binary-ast/print_magic_number.ml create mode 100644 test/driver/standalone-supports-old-binary-ast/test.t/406_binary_ast create mode 100644 test/driver/standalone-supports-old-binary-ast/test.t/run.t diff --git a/test/driver/standalone-supports-old-binary-ast/dune b/test/driver/standalone-supports-old-binary-ast/dune new file mode 100644 index 000000000..9b74d4f75 --- /dev/null +++ b/test/driver/standalone-supports-old-binary-ast/dune @@ -0,0 +1,19 @@ +(executable + (name identity_standalone) + (libraries ppxlib) + (modules identity_standalone)) + +(executable + (name print_magic_number) + (libraries astlib) + (modules print_magic_number)) + +(cram + (enabled_if + (or + (= %{system} linux) + (= %{system} linux_elf) + (= %{system} elf) + (= %{system} linux_eabihf) + (= %{system} linux_eabi))) + (deps identity_standalone.exe print_magic_number.exe)) diff --git a/test/driver/standalone-supports-old-binary-ast/identity_standalone.ml b/test/driver/standalone-supports-old-binary-ast/identity_standalone.ml new file mode 100644 index 000000000..e3cba4049 --- /dev/null +++ b/test/driver/standalone-supports-old-binary-ast/identity_standalone.ml @@ -0,0 +1 @@ +let () = Ppxlib.Driver.standalone () diff --git a/test/driver/standalone-supports-old-binary-ast/print_magic_number.ml b/test/driver/standalone-supports-old-binary-ast/print_magic_number.ml new file mode 100644 index 000000000..ebac13c2f --- /dev/null +++ b/test/driver/standalone-supports-old-binary-ast/print_magic_number.ml @@ -0,0 +1,5 @@ +let magic_length = String.length Astlib.Config.ast_impl_magic_number +let buf = Bytes.create magic_length +let len = input stdin buf 0 magic_length +let s = Bytes.sub_string buf 0 len +let () = Printf.printf "Magic number: %s" s diff --git a/test/driver/standalone-supports-old-binary-ast/test.t/406_binary_ast b/test/driver/standalone-supports-old-binary-ast/test.t/406_binary_ast new file mode 100644 index 0000000000000000000000000000000000000000..c9f489920b62c1c06dc235261adc4011854f6835 GIT binary patch literal 460 zcmXv|!AiqG6inq^tl*&_y?9YtwOSk7gHXI|Q9%S-sDhwK+-_c*v`IE(H_{LA1M0z( zm*7DVFZlxT&-87IFtfYt%)B?JJPg|1ZnuBb={&!Fd|Q?^AeM+5#I@Bc+mj*MN=8#| zpGlF17-?nS@Wgjf*>NJLDClG4E4rOHp4%FgwnwR$1*k;g$J+KV2xKckf4QP`L8BjO z%RaH1Wp7#5mV%nJDBcn>(m2=o&yEwx2%R3Yeqp7z$g(W|qGQp}QU*@MLxlDG<$Z66 z*TotJ6=w9NABiA!(Q*AmK{fx(7Tfm^u*nETK9JmXVy->dA`!|^V}v3qV~m_ox+!&s zhEXffWCWugjAcSOG2;`2wwYV&Q$sjr1Y@YXI7%mQQb;;U5f~#B*;JvUy#%?d;M^GM rV;(4kOGYq`L*sY~|2+e Date: Fri, 16 Feb 2024 12:05:38 +0100 Subject: [PATCH 2/7] Add migrations for ppx.context's load_path Signed-off-by: Nathan Rebours --- astlib/migrate_501_502.ml | 61 +++++++++++- astlib/migrate_502_501.ml | 48 +++++++++- .../driver.ml | 92 +++++++++++++++++++ .../dune | 13 +++ .../run.t | 76 +++++++++++++++ .../test.t/run.t | 6 +- 6 files changed, 286 insertions(+), 10 deletions(-) create mode 100644 test/driver/ocaml-ppx-context-load-path-migration/driver.ml create mode 100644 test/driver/ocaml-ppx-context-load-path-migration/dune create mode 100644 test/driver/ocaml-ppx-context-load-path-migration/run.t diff --git a/astlib/migrate_501_502.ml b/astlib/migrate_501_502.ml index 641bb7ec5..5204f02d1 100644 --- a/astlib/migrate_501_502.ml +++ b/astlib/migrate_501_502.ml @@ -7,13 +7,62 @@ module To = Ast_502 attribute is not found. *) let extract_attr name (attrs : Ast_501.Parsetree.attributes) = let rec loop acc = function - | [] -> (false, List.rev acc) - | { Ast_501.Parsetree.attr_name = { txt; _ }; _ } :: q when txt = name -> - (true, List.rev_append acc q) + | [] -> (None, List.rev acc) + | { Ast_501.Parsetree.attr_name = { txt; _ }; attr_payload; _ } :: q + when txt = name -> + (Some attr_payload, List.rev_append acc q) | hd :: tl -> loop (hd :: acc) tl in loop [] attrs +let migrate_ppx_context_load_path expr = + let open Ast_501.Parsetree in + let visible = { expr with pexp_attributes = [] } in + let payload, other_attrs = + extract_attr "ppxlib.migration.hidden_load_path" expr.pexp_attributes + in + let hidden = + match payload with + | None -> + (* An empty list *) + let pexp_desc = + Pexp_construct ({ txt = Lident "[]"; loc = expr.pexp_loc }, None) + in + { expr with pexp_desc; pexp_attributes = [] } + | Some (PStr [ { pstr_desc = Pstr_eval (expr, []); _ } ]) -> expr + | Some _ -> invalid_arg "Invalid ppxlib.migration.hidden_load_path paylaod" + in + { + expr with + pexp_attributes = other_attrs; + pexp_desc = Pexp_tuple [ visible; hidden ]; + } + +let migrate_ppx_context_fields fields = + List.map + (fun (lident_loc, expr) -> + match lident_loc.Ast_501.Asttypes.txt with + | Longident.Lident "load_path" -> + (lident_loc, migrate_ppx_context_load_path expr) + | _ -> (lident_loc, expr)) + fields + +let migrate_ppx_context_payload payload = + let open Ast_501.Parsetree in + match payload with + | PStr + [ + ({ + pstr_desc = + Pstr_eval + (({ pexp_desc = Pexp_record (fields, None) } as expr), attributes); + } as stri); + ] -> + let new_fields = migrate_ppx_context_fields fields in + let new_expr = { expr with pexp_desc = Pexp_record (new_fields, None) } in + PStr [ { stri with pstr_desc = Pstr_eval (new_expr, attributes) } ] + | _ -> payload + let rec copy_toplevel_phrase : Ast_501.Parsetree.toplevel_phrase -> Ast_502.Parsetree.toplevel_phrase = function @@ -514,7 +563,11 @@ and copy_attribute : Ast_501.Parsetree.attribute -> Ast_502.Parsetree.attribute } -> { Ast_502.Parsetree.attr_name = copy_loc (fun x -> x) attr_name; - Ast_502.Parsetree.attr_payload = copy_payload attr_payload; + Ast_502.Parsetree.attr_payload = + (match attr_name.txt with + | "ocaml.ppx.context" -> + copy_payload (migrate_ppx_context_payload attr_payload) + | _ -> copy_payload attr_payload); Ast_502.Parsetree.attr_loc = copy_location attr_loc; } diff --git a/astlib/migrate_502_501.ml b/astlib/migrate_502_501.ml index b756d8900..c7af15a86 100644 --- a/astlib/migrate_502_501.ml +++ b/astlib/migrate_502_501.ml @@ -13,6 +13,48 @@ let mk_ghost_attr name = attr_loc = Location.none; } +let migrate_ppx_context_load_path expr = + let open Ast_502.Parsetree in + let loc = Location.none in + match expr.pexp_desc with + | Pexp_tuple [ visible; hidden ] -> + let hidden_attr = + { + attr_name = + { Location.txt = "ppxlib.migration.hidden_load_path"; loc }; + attr_loc = loc; + attr_payload = + PStr [ { pstr_loc = loc; pstr_desc = Pstr_eval (hidden, []) } ]; + } + in + { visible with pexp_attributes = hidden_attr :: expr.pexp_attributes } + | _ -> expr + +let migrate_ppx_context_fields fields = + List.map + (fun (lident_loc, expr) -> + match lident_loc.Ast_502.Asttypes.txt with + | Longident.Lident "load_path" -> + (lident_loc, migrate_ppx_context_load_path expr) + | _ -> (lident_loc, expr)) + fields + +let migrate_ppx_context_payload payload = + let open Ast_502.Parsetree in + match payload with + | PStr + [ + ({ + pstr_desc = + Pstr_eval + (({ pexp_desc = Pexp_record (fields, None) } as expr), attributes); + } as stri); + ] -> + let new_fields = migrate_ppx_context_fields fields in + let new_expr = { expr with pexp_desc = Pexp_record (new_fields, None) } in + PStr [ { stri with pstr_desc = Pstr_eval (new_expr, attributes) } ] + | _ -> payload + let rec copy_toplevel_phrase : Ast_502.Parsetree.toplevel_phrase -> Ast_501.Parsetree.toplevel_phrase = function @@ -511,7 +553,11 @@ and copy_attribute : Ast_502.Parsetree.attribute -> Ast_501.Parsetree.attribute } -> { Ast_501.Parsetree.attr_name = copy_loc (fun x -> x) attr_name; - Ast_501.Parsetree.attr_payload = copy_payload attr_payload; + Ast_501.Parsetree.attr_payload = + (match attr_name.txt with + | "ocaml.ppx.context" -> + copy_payload (migrate_ppx_context_payload attr_payload) + | _ -> copy_payload attr_payload); Ast_501.Parsetree.attr_loc = copy_location attr_loc; } diff --git a/test/driver/ocaml-ppx-context-load-path-migration/driver.ml b/test/driver/ocaml-ppx-context-load-path-migration/driver.ml new file mode 100644 index 000000000..048d91bb8 --- /dev/null +++ b/test/driver/ocaml-ppx-context-load-path-migration/driver.ml @@ -0,0 +1,92 @@ +module To_before_502 = + Ppxlib_ast.Convert (Ppxlib_ast.Js) (Ppxlib_ast__.Versions.OCaml_501) + +module From_before_502 = + Ppxlib_ast.Convert (Ppxlib_ast__.Versions.OCaml_501) (Ppxlib_ast.Js) + +module Before_502_to_ocaml = + Ppxlib_ast.Convert + (Ppxlib_ast__.Versions.OCaml_501) + (Ppxlib_ast.Compiler_version) + +module OCaml_501 = Ppxlib_ast__.Versions.OCaml_501.Ast + +let rec unfold_list_lit x next = + let open OCaml_501.Parsetree in + let open Astlib.Longident in + match next.pexp_desc with + | Pexp_construct ({ txt = Lident "[]"; _ }, None) -> [ x ] + | Pexp_construct + ( { txt = Lident "::"; _ }, + Some { pexp_desc = Pexp_tuple [ elm; rest ]; _ } ) -> + x :: unfold_list_lit elm rest + | _ -> invalid_arg "list_lit" + +(* Only deals with the basic blocks needed for ocaml.ppx.context *) +let rec basic_expr_to_string expr = + let open OCaml_501.Parsetree in + let open Astlib.Longident in + match expr.pexp_desc with + | Pexp_constant (Pconst_string (s, _, None)) -> Printf.sprintf "%S" s + | Pexp_ident { txt = Lident name; _ } -> name + | Pexp_tuple l -> + let strs = List.map basic_expr_to_string l in + "(" ^ String.concat ", " strs ^ ")" + | Pexp_construct ({ txt = Lident s; _ }, None) -> s + | Pexp_construct + ( { txt = Lident "::"; _ }, + Some { pexp_desc = Pexp_tuple [ elm; rest ]; _ } ) -> + let exprs = unfold_list_lit elm rest in + let strs = List.map basic_expr_to_string exprs in + "[" ^ String.concat "; " strs ^ "]" + | _ -> invalid_arg "basic_expr_to_string" + +let print_field (lident_loc, expr) = + match lident_loc with + | { OCaml_501.Asttypes.txt = Astlib.Longident.Lident name; _ } -> + Printf.printf " %s: %s;\n" name (basic_expr_to_string expr) + | _ -> () + +let print_ocaml_ppx_context stri = + let open OCaml_501.Parsetree in + match stri.pstr_desc with + | Pstr_attribute + { + attr_payload = + PStr + [ + { + pstr_desc = + Pstr_eval ({ pexp_desc = Pexp_record (fields, None); _ }, _); + _; + }; + ]; + _; + } -> + Printf.printf "[@@@ocaml.ppx.context\n"; + Printf.printf " {\n"; + List.iter print_field fields; + Printf.printf " }\n"; + Printf.printf "]\n" + | _ -> () + +let is_ppx_context stri = + let open OCaml_501.Parsetree in + match stri.pstr_desc with + | Pstr_attribute + { attr_name = { OCaml_501.Asttypes.txt = "ocaml.ppx.context"; _ }; _ } -> + true + | _ -> false + +let impl _ctxt str = + let before_502_ast = To_before_502.copy_structure str in + let ppx_context = List.find is_ppx_context before_502_ast in + Printf.printf "ocaml.ppx.context before 5.02:\n"; + print_ocaml_ppx_context ppx_context; + let round_trip = Before_502_to_ocaml.copy_structure_item ppx_context in + Printf.printf "ocaml.ppx.context round tripped:\n"; + Ocaml_common.Pprintast.structure_item Format.std_formatter round_trip; + From_before_502.copy_structure before_502_ast + +let () = Ppxlib.Driver.V2.register_transformation ~impl "ocaml.ppx.context-test" +let () = Ppxlib.Driver.standalone () diff --git a/test/driver/ocaml-ppx-context-load-path-migration/dune b/test/driver/ocaml-ppx-context-load-path-migration/dune new file mode 100644 index 000000000..e5acf6f7d --- /dev/null +++ b/test/driver/ocaml-ppx-context-load-path-migration/dune @@ -0,0 +1,13 @@ +; Remember to bump the enabled if to the latest supported OCaml + +(executable + (name driver) + (enabled_if + (>= %{ocaml_version} "5.2")) + (libraries ppxlib ppxlib.ast ppxlib.astlib ocaml-compiler-libs.common + compiler-libs.common)) + +(cram + (enabled_if + (>= %{ocaml_version} "5.2")) + (deps driver.exe)) diff --git a/test/driver/ocaml-ppx-context-load-path-migration/run.t b/test/driver/ocaml-ppx-context-load-path-migration/run.t new file mode 100644 index 000000000..b3de2c035 --- /dev/null +++ b/test/driver/ocaml-ppx-context-load-path-migration/run.t @@ -0,0 +1,76 @@ +Note that this test shoud only be enabled with the latest supported OCaml +version. + +In 5.2 the format of ocaml.ppx.context load_path changed. +To ensure compat, we defined migration for ocaml.ppx.context attributes + +We write such an attribute to an .ml file. The compiler will add its own +and it should be consumed by the driver but our handwritten attribute will +be migrated as well and should remain in the AST. + $ cat > test.ml << EOF + > let x = 1 + > [@@@ocaml.ppx.context + > { + > tool_name = "ocaml"; + > include_dirs = ["foo"]; + > hidden_include_dirs = []; + > load_path = (["foo"; "bar"], ["baz"]); + > open_modules = []; + > for_package = None; + > debug = true; + > use_threads = false; + > use_vmthreads = false; + > recursive_types = false; + > principal = false; + > transparent_modules = false; + > unboxed_types = false; + > unsafe_string = false; + > cookies = [] + > }] + > EOF + +We then run a custom driver that will read our ast, migrate it back to 5.01, +pretty print the ocaml.ppx.context, convert it back to the latest version and +pretty print it again. This last, round-tripped version should be identical to +the one above. + + $ ./driver.exe --impl test.ml -o ignore.ml + ocaml.ppx.context before 5.02: + [@@@ocaml.ppx.context + { + tool_name: "ocaml"; + include_dirs: ["foo"]; + hidden_include_dirs: []; + load_path: ["foo"; "bar"]; + open_modules: []; + for_package: None; + debug: true; + use_threads: false; + use_vmthreads: false; + recursive_types: false; + principal: false; + transparent_modules: false; + unboxed_types: false; + unsafe_string: false; + cookies: []; + } + ] + ocaml.ppx.context round tripped: + [@@@ocaml.ppx.context + { + tool_name = "ocaml"; + include_dirs = ["foo"]; + hidden_include_dirs = []; + load_path = (["foo"; "bar"], ["baz"]); + open_modules = []; + for_package = None; + debug = true; + use_threads = false; + use_vmthreads = false; + recursive_types = false; + principal = false; + transparent_modules = false; + unboxed_types = false; + unsafe_string = false; + cookies = [] + }] diff --git a/test/driver/standalone-supports-old-binary-ast/test.t/run.t b/test/driver/standalone-supports-old-binary-ast/test.t/run.t index c269cb162..8baa6e853 100644 --- a/test/driver/standalone-supports-old-binary-ast/test.t/run.t +++ b/test/driver/standalone-supports-old-binary-ast/test.t/run.t @@ -5,10 +5,6 @@ The version is preserved. Magic number: Caml1999N022 $ ../identity_standalone.exe --intf 406_binary_ast -o transformed --dump-ast - File "_none_", line 1: - Error: Internal error: invalid [@@ocaml.ppx.context { load_path }] pair syntax - [1] $ ../print_magic_number.exe < transformed - cannot open transformed: No such file - [2] + Magic number: Caml1999N022 From 2283c6cdef1c4ff85a69c2a582210a9b1e731dae Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Wed, 21 Feb 2024 15:30:13 +0100 Subject: [PATCH 3/7] Merge visible and hidden load_path when migrating to 5.1 Signed-off-by: Nathan Rebours --- astlib/migrate_501_502.ml | 33 +++++++++---------- astlib/migrate_502_501.ml | 33 ++++++++++++++++--- .../run.t | 2 +- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/astlib/migrate_501_502.ml b/astlib/migrate_501_502.ml index 5204f02d1..61b1bdaa3 100644 --- a/astlib/migrate_501_502.ml +++ b/astlib/migrate_501_502.ml @@ -17,26 +17,23 @@ let extract_attr name (attrs : Ast_501.Parsetree.attributes) = let migrate_ppx_context_load_path expr = let open Ast_501.Parsetree in - let visible = { expr with pexp_attributes = [] } in let payload, other_attrs = - extract_attr "ppxlib.migration.hidden_load_path" expr.pexp_attributes + extract_attr "ppxlib.migration.load_path" expr.pexp_attributes in - let hidden = - match payload with - | None -> - (* An empty list *) - let pexp_desc = - Pexp_construct ({ txt = Lident "[]"; loc = expr.pexp_loc }, None) - in - { expr with pexp_desc; pexp_attributes = [] } - | Some (PStr [ { pstr_desc = Pstr_eval (expr, []); _ } ]) -> expr - | Some _ -> invalid_arg "Invalid ppxlib.migration.hidden_load_path paylaod" - in - { - expr with - pexp_attributes = other_attrs; - pexp_desc = Pexp_tuple [ visible; hidden ]; - } + match payload with + | None -> + let pexp_desc = + Pexp_construct ({ txt = Lident "[]"; loc = expr.pexp_loc }, None) + in + let hidden = { expr with pexp_desc; pexp_attributes = [] } in + let visible = expr in + { + expr with + pexp_attributes = other_attrs; + pexp_desc = Pexp_tuple [ visible; hidden ]; + } + | Some (PStr [ { pstr_desc = Pstr_eval (expr, []); _ } ]) -> expr + | Some _ -> invalid_arg "Invalid ppxlib.migration.load_path paylaod" let migrate_ppx_context_fields fields = List.map diff --git a/astlib/migrate_502_501.ml b/astlib/migrate_502_501.ml index c7af15a86..fead8f70f 100644 --- a/astlib/migrate_502_501.ml +++ b/astlib/migrate_502_501.ml @@ -13,21 +13,44 @@ let mk_ghost_attr name = attr_loc = Location.none; } +let rec concat_list_lit left right = + let open Ast_502.Parsetree in + let open Ast_502.Asttypes in + match (left.pexp_desc, right.pexp_desc) with + | _, Pexp_construct ({ txt = Lident "[]"; _ }, _) -> left + | Pexp_construct ({ txt = Lident "[]"; _ }, _), _ -> right + | ( Pexp_construct + ( { txt = Lident "::"; loc }, + Some ({ pexp_desc = Pexp_tuple [ hd; tl ]; _ } as arg_expr) ), + _ ) -> + { + left with + pexp_desc = + Pexp_construct + ( { txt = Lident "::"; loc }, + Some + { + arg_expr with + pexp_desc = Pexp_tuple [ hd; concat_list_lit tl right ]; + } ); + } + | _ -> invalid_arg "Invalid ocaml.ppx.context's load_path" + let migrate_ppx_context_load_path expr = let open Ast_502.Parsetree in let loc = Location.none in match expr.pexp_desc with | Pexp_tuple [ visible; hidden ] -> - let hidden_attr = + let migration_attr = { - attr_name = - { Location.txt = "ppxlib.migration.hidden_load_path"; loc }; + attr_name = { Location.txt = "ppxlib.migration.load_path"; loc }; attr_loc = loc; attr_payload = - PStr [ { pstr_loc = loc; pstr_desc = Pstr_eval (hidden, []) } ]; + PStr [ { pstr_loc = loc; pstr_desc = Pstr_eval (expr, []) } ]; } in - { visible with pexp_attributes = hidden_attr :: expr.pexp_attributes } + let expr' = concat_list_lit visible hidden in + { expr' with pexp_attributes = migration_attr :: expr.pexp_attributes } | _ -> expr let migrate_ppx_context_fields fields = diff --git a/test/driver/ocaml-ppx-context-load-path-migration/run.t b/test/driver/ocaml-ppx-context-load-path-migration/run.t index b3de2c035..2786f3b6a 100644 --- a/test/driver/ocaml-ppx-context-load-path-migration/run.t +++ b/test/driver/ocaml-ppx-context-load-path-migration/run.t @@ -41,7 +41,7 @@ the one above. tool_name: "ocaml"; include_dirs: ["foo"]; hidden_include_dirs: []; - load_path: ["foo"; "bar"]; + load_path: ["foo"; "bar"; "baz"]; open_modules: []; for_package: None; debug: true; From 031dd11883388ab4f26f8ebdc4747c27d368fdf1 Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Mon, 26 Feb 2024 12:49:48 +0100 Subject: [PATCH 4/7] Fix typo in load_path migration error message Signed-off-by: Nathan Rebours Co-authored-by: Antonio Nuno Monteiro --- astlib/migrate_501_502.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astlib/migrate_501_502.ml b/astlib/migrate_501_502.ml index 61b1bdaa3..dbca4fdb9 100644 --- a/astlib/migrate_501_502.ml +++ b/astlib/migrate_501_502.ml @@ -33,7 +33,7 @@ let migrate_ppx_context_load_path expr = pexp_desc = Pexp_tuple [ visible; hidden ]; } | Some (PStr [ { pstr_desc = Pstr_eval (expr, []); _ } ]) -> expr - | Some _ -> invalid_arg "Invalid ppxlib.migration.load_path paylaod" + | Some _ -> invalid_arg "Invalid ppxlib.migration.load_path payload" let migrate_ppx_context_fields fields = List.map From 993b85c875e7736e33c596aeeec86963013a28e8 Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Mon, 18 Mar 2024 12:25:04 +0100 Subject: [PATCH 5/7] Remove unnecessary migration in ocaml-ppx-context test Signed-off-by: Nathan Rebours --- test/driver/ocaml-ppx-context-load-path-migration/driver.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/driver/ocaml-ppx-context-load-path-migration/driver.ml b/test/driver/ocaml-ppx-context-load-path-migration/driver.ml index 048d91bb8..da781e210 100644 --- a/test/driver/ocaml-ppx-context-load-path-migration/driver.ml +++ b/test/driver/ocaml-ppx-context-load-path-migration/driver.ml @@ -86,7 +86,7 @@ let impl _ctxt str = let round_trip = Before_502_to_ocaml.copy_structure_item ppx_context in Printf.printf "ocaml.ppx.context round tripped:\n"; Ocaml_common.Pprintast.structure_item Format.std_formatter round_trip; - From_before_502.copy_structure before_502_ast + str let () = Ppxlib.Driver.V2.register_transformation ~impl "ocaml.ppx.context-test" let () = Ppxlib.Driver.standalone () From 7d036105e0459d6968fb83aec82deefb0f9d02fe Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Mon, 18 Mar 2024 12:30:26 +0100 Subject: [PATCH 6/7] Preserve location when migrating ocaml.ppx.context attr Signed-off-by: Nathan Rebours --- astlib/migrate_502_501.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astlib/migrate_502_501.ml b/astlib/migrate_502_501.ml index fead8f70f..12d94b5e0 100644 --- a/astlib/migrate_502_501.ml +++ b/astlib/migrate_502_501.ml @@ -38,7 +38,7 @@ let rec concat_list_lit left right = let migrate_ppx_context_load_path expr = let open Ast_502.Parsetree in - let loc = Location.none in + let loc = expr.pexp_loc in match expr.pexp_desc with | Pexp_tuple [ visible; hidden ] -> let migration_attr = From fdca4b3125c66036dee95963924629b4798fe41b Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Wed, 20 Mar 2024 09:41:37 +0100 Subject: [PATCH 7/7] Remove suggestions to keep ocaml-ppx-context test for latest compiler Signed-off-by: Nathan Rebours --- test/driver/ocaml-ppx-context-load-path-migration/dune | 2 -- test/driver/ocaml-ppx-context-load-path-migration/run.t | 3 --- 2 files changed, 5 deletions(-) diff --git a/test/driver/ocaml-ppx-context-load-path-migration/dune b/test/driver/ocaml-ppx-context-load-path-migration/dune index e5acf6f7d..e55826656 100644 --- a/test/driver/ocaml-ppx-context-load-path-migration/dune +++ b/test/driver/ocaml-ppx-context-load-path-migration/dune @@ -1,5 +1,3 @@ -; Remember to bump the enabled if to the latest supported OCaml - (executable (name driver) (enabled_if diff --git a/test/driver/ocaml-ppx-context-load-path-migration/run.t b/test/driver/ocaml-ppx-context-load-path-migration/run.t index 2786f3b6a..124e7f674 100644 --- a/test/driver/ocaml-ppx-context-load-path-migration/run.t +++ b/test/driver/ocaml-ppx-context-load-path-migration/run.t @@ -1,6 +1,3 @@ -Note that this test shoud only be enabled with the latest supported OCaml -version. - In 5.2 the format of ocaml.ppx.context load_path changed. To ensure compat, we defined migration for ocaml.ppx.context attributes