Skip to content

Commit

Permalink
Compat with OCaml 5.3.0~alpha1
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow committed Sep 30, 2024
1 parent f3b0823 commit 6119c82
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
4 changes: 4 additions & 0 deletions src/loader/cmi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/loader/doc_attr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/syntax_highlighter/syntax_highlighter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/xref2/shape_tools.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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

Expand Down
4 changes: 3 additions & 1 deletion test/xref2/lib/common.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,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, PageName.make_std "None")
Expand Down
2 changes: 1 addition & 1 deletion test/xref2/module_preamble.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 4 additions & 22 deletions test/xref2/module_type_of_extra.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,10 @@ More advanced uses of `module type of`, including using functors.

$ ocamlc -c -bin-annot a.mli
$ ocamlc -c -bin-annot b.mli
$ ocamlc -i b.mli
module X : sig type t end
module type X1 = sig type t end
module type X2 = sig module X : sig type t end end
module type X3 = sig type t end
module Y : functor (A : sig type t end) -> sig type t end
module type Foo =
sig
module X : sig type t end
module Y : functor (A : sig type t end) -> sig module Z = X end
module type Z = functor (A : sig type t end) -> sig module Z = X end
module X' : sig type t = X.t end
end
module type X4 = functor (A : sig type t end) -> sig type t end
module SubX : sig type t type u end
module type X5 =
sig
module Y : functor (A : sig type t end) -> sig module Z = SubX end
module type Z = functor (A : sig type t end) -> sig module Z = SubX end
module X' : sig type t = SubX.t end
end
module type X6 = sig type t end

Omitted for stability:
$ ocamlc -i b.mli

$ odoc compile a.cmti
$ odoc compile -I . b.cmti
$ odoc link -I . a.odoc
Expand Down

0 comments on commit 6119c82

Please sign in to comment.