From 58f05793af7a71b924f4bbefed968dece489f4e1 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 30 Sep 2024 14:41:53 +0200 Subject: [PATCH] Compat with OCaml 5.3.0~alpha1 --- src/loader/cmi.ml | 4 ++++ src/loader/doc_attr.ml | 4 +++- src/syntax_highlighter/syntax_highlighter.ml | 6 ++++++ src/xref2/shape_tools.cppo.ml | 2 +- test/xref2/lib/common.cppo.ml | 4 +++- test/xref2/module_preamble.t/run.t | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/loader/cmi.ml b/src/loader/cmi.ml index bfed4220b7..7dee2545f5 100644 --- a/src/loader/cmi.ml +++ b/src/loader/cmi.ml @@ -27,6 +27,10 @@ module Paths = Odoc_model.Paths module Compat = struct #if OCAML_VERSION >= (4, 14, 0) +#if OCAML_VERSION >= (5, 3, 0) + let newty2 = Btype.newty2 +#endif + (** this is the type on which physical equality is meaningful *) type repr_type_node = Types.transient_expr diff --git a/src/loader/doc_attr.ml b/src/loader/doc_attr.ml index a4e9fd8aab..892688104d 100644 --- a/src/loader/doc_attr.ml +++ b/src/loader/doc_attr.ml @@ -39,8 +39,10 @@ let load_constant_string = function Pexp_constant (Const_string (text, _)) #elif OCAML_VERSION < (4,11,0) Pexp_constant (Pconst_string (text, _)) -#else +#elif OCAML_VERSION < (5,3,0) Pexp_constant (Pconst_string (text, _, _)) +#else + Pexp_constant {pconst_desc= Pconst_string (text, _, _); _} #endif ; pexp_loc = loc; _} -> Some (text , loc) diff --git a/src/syntax_highlighter/syntax_highlighter.ml b/src/syntax_highlighter/syntax_highlighter.ml index e6199372b2..688b85cc62 100644 --- a/src/syntax_highlighter/syntax_highlighter.ml +++ b/src/syntax_highlighter/syntax_highlighter.ml @@ -145,6 +145,12 @@ let tag_of_token (tok : Parser.token) = | ANDOP _ -> "ANDOP" | LETOP _ -> "LETOP" #endif +#if OCAML_VERSION >= (5,3,0) + | METAOCAML_ESCAPE -> "METAOCAML_ESCAPE" + | METAOCAML_BRACKET_OPEN -> "METAOCAML_BRACKET_OPEN" + | METAOCAML_BRACKET_CLOSE -> "METAOCAML_BRACKET_CLOSE" + | EFFECT -> "EFFECT" +#endif let syntax_highlighting_locs src = let lexbuf = Lexing.from_string diff --git a/src/xref2/shape_tools.cppo.ml b/src/xref2/shape_tools.cppo.ml index 59398514bf..a9fa4285f4 100644 --- a/src/xref2/shape_tools.cppo.ml +++ b/src/xref2/shape_tools.cppo.ml @@ -58,7 +58,7 @@ module MkId = Identifier.Mk let unit_of_uid uid = match uid with | Shape.Uid.Compilation_unit s -> Some s - | Item { comp_unit; id = _ } -> Some comp_unit + | Item { comp_unit; _ } -> Some comp_unit | Predef _ -> None | Internal -> None diff --git a/test/xref2/lib/common.cppo.ml b/test/xref2/lib/common.cppo.ml index 94de1857fc..8367b06574 100644 --- a/test/xref2/lib/common.cppo.ml +++ b/test/xref2/lib/common.cppo.ml @@ -34,8 +34,10 @@ let cmt_of_string s = let p = Parse.implementation l in #if OCAML_VERSION < (5,2,0) Typemod.type_implementation "" "" "" env p -#else +#elif OCAML_VERSION < (5,3,0) Typemod.type_implementation (Unit_info.make ~source_file:"" "") env p +#else + Typemod.type_implementation Unit_info.(make ~source_file:"" Impl "") env p #endif let parent = Odoc_model.Paths.Identifier.Mk.page (None, Odoc_model.Names.PageName.make_std "None") diff --git a/test/xref2/module_preamble.t/run.t b/test/xref2/module_preamble.t/run.t index f5e09a080c..b4f951b337 100644 --- a/test/xref2/module_preamble.t/run.t +++ b/test/xref2/module_preamble.t/run.t @@ -9,7 +9,7 @@ and that "hidden" modules (eg. `A__b`, rendered to `html/A__b`) are not rendered $ ocamlc -bin-annot -o a__b.cmo -c b.ml $ ocamlc -bin-annot -o a.cmi -c a.mli $ ocamlc -bin-annot -o a.cmo -c a.ml - $ ocamlc -bin-annot -a -o a.cma a.cmo a__b.cmo + $ ocamlc -bin-annot -a -o a.cma a__b.cmo a.cmo $ odoc compile --pkg test -o a__b.odoc -I . a__b.cmti $ odoc compile --pkg test -o a.odoc -I . a.cmti