diff --git a/CHANGES.md b/CHANGES.md index 7203c4eeac..55356513d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,13 @@ # Unreleased +### Added - Support for OxCaml unboxed named types (@art-w, #1407) - Support for OxCaml zero alloc definitions (@Leonidas-from-XIV, #1422, #1444) -- Remove requirement for ppx_expect in tests (@jonludlam, #1445) - Support for OxCaml modalities (@art-w, #1420) +- Support OxCaml 5.2.0minus39 (@jonludlam, #1469) + +### Fixed +- Remove requirement for ppx_expect in tests (@jonludlam, #1445) - Fix resolving functor through `module type of` (@Leonidas-from-XIV, #1471) # 3.2.1 diff --git a/odoc.opam b/odoc.opam index 21565bd8b4..5ad7d031f7 100644 --- a/odoc.opam +++ b/odoc.opam @@ -58,7 +58,7 @@ depends: [ conflicts: [ "ocaml-option-bytecode-only" - "oxcaml-compiler" {< "5.2.0minus31"} + "oxcaml-compiler" {< "5.2.0minus39"} ] x-extra-doc-deps: [ diff --git a/src/loader/cmi.ml b/src/loader/cmi.ml index bc30e26666..756ee7ef63 100644 --- a/src/loader/cmi.ml +++ b/src/loader/cmi.ml @@ -315,6 +315,7 @@ let mark_type ty = | Tlink _ -> assert false #if defined OXCAML | Tquote typ -> loop visited typ + | Tquote_eval typ -> loop visited typ | Tsplice typ -> loop visited typ | Tof_kind _ -> () | Trepr _ -> () @@ -499,7 +500,7 @@ let rec read_jkind_annotation (jk : Parsetree.jkind_annotation) = let open Kind in match jk.pjka_desc with | Pjk_default -> Default - | Pjk_abbreviation s -> Abbreviation (Env.Fragment.read_type s.txt) + | Pjk_abbreviation (s, _) -> Abbreviation (Env.Fragment.read_type s.txt) | Pjk_mod (jk', modes) -> let modes = List.map (fun (m : Parsetree.mode Location.loc) -> let (Parsetree.Mode s) = m.txt in s) modes in @@ -665,6 +666,7 @@ let rec read_type_expr env typ = | Tlink _ -> assert false #if defined OXCAML | Tquote typ -> Quote (read_type_expr env typ) + | Tquote_eval typ -> Quote (read_type_expr env typ) | Tsplice typ -> Splice (read_type_expr env typ) | Tof_kind _ -> assert false | Trepr _ -> Any (* oxcaml: representation annotations are ignored *) diff --git a/src/loader/cmt.ml b/src/loader/cmt.ml index d00b5d3e97..3681016038 100644 --- a/src/loader/cmt.ml +++ b/src/loader/cmt.ml @@ -44,7 +44,7 @@ let rec read_pattern env parent doc id_attrs pat = #if OCAML_VERSION < (5,2,0) | Tpat_var(id, _) -> #elif defined OXCAML - | Tpat_var(id, _, _uid, _, _) -> + | Tpat_var { id; _ } -> #else | Tpat_var(id, _, _uid) -> #endif @@ -58,7 +58,7 @@ let rec read_pattern env parent doc id_attrs pat = #if OCAML_VERSION < (5,2, 0) | Tpat_alias(pat, id, _) -> #elif defined OXCAML - | Tpat_alias(pat, id, _, _, _, _, _) -> + | Tpat_alias { pattern = pat; id; _ } -> #elif OCAML_VERSION < (5,4,0) | Tpat_alias(pat, id, _,_) -> #else @@ -120,6 +120,7 @@ let rec read_pattern env parent doc id_attrs pat = #if defined OXCAML | Tpat_unboxed_unit -> [] | Tpat_unboxed_bool _ -> [] + | Tpat_fun_layout _ -> [] #endif let read_value_binding env parent id_attrs vb = diff --git a/src/loader/cmti.ml b/src/loader/cmti.ml index 10fda71abc..236478fa7e 100644 --- a/src/loader/cmti.ml +++ b/src/loader/cmti.ml @@ -163,6 +163,9 @@ let rec read_core_type env container ctyp = | Ttyp_call_pos -> Constr(Env.Path.read_type env.ident_env Predef.path_lexing_position, []) | Ttyp_of_kind _ -> assert false | Ttyp_repr _ -> Any (* oxcaml: representation annotations are ignored *) + | Ttyp_newlayout (_, ct) -> + (* oxcaml: layout-variable binder; odoc ignores the layout vars *) + read_core_type env container ct #elif OCAML_VERSION >= (5,5,0) | Ttyp_functor (lbl, id, pkg, ret_type) -> let lbl = read_label lbl in @@ -586,28 +589,33 @@ let rec read_with_constraint env global_parent parent (_, frag, constr) = | Twith_type decl -> let frag = Env.Fragment.read_type frag.Location.txt in let eq = read_type_equation env parent decl in - TypeEq(frag, eq) + Some (TypeEq(frag, eq)) | Twith_module(p, _) -> let frag = Env.Fragment.read_module frag.Location.txt in let eq = read_module_equation env p in - ModuleEq(frag, eq) + Some (ModuleEq(frag, eq)) | Twith_typesubst decl -> let frag = Env.Fragment.read_type frag.Location.txt in let eq = read_type_equation env parent decl in - TypeSubst(frag, eq) + Some (TypeSubst(frag, eq)) | Twith_modsubst(p, _) -> let frag = Env.Fragment.read_module frag.Location.txt in let p = Env.Path.read_module env.ident_env p in - ModuleSubst(frag, p) + Some (ModuleSubst(frag, p)) #if OCAML_VERSION >= (4,13,0) | Twith_modtype mty -> let frag = Env.Fragment.read_module_type frag.Location.txt in let mty = read_module_type env global_parent parent mty in - ModuleTypeEq(frag, mty) + Some (ModuleTypeEq(frag, mty)) | Twith_modtypesubst mty -> let frag = Env.Fragment.read_module_type frag.Location.txt in let mty = read_module_type env global_parent parent mty in - ModuleTypeSubst(frag, mty) + Some (ModuleTypeSubst(frag, mty)) +#endif +#if defined OXCAML + (* oxcaml: [with kind] constraints have no representation in odoc's + model, so they are dropped. *) + | Twith_jkind _ | Twith_jkindsubst _ -> None #endif and read_module_type env parent label_parent mty = @@ -671,7 +679,7 @@ and read_module_type env parent label_parent mty = #endif | Tmty_with(body, subs) -> ( let body = read_module_type env parent label_parent body in - let subs = List.map (read_with_constraint env parent label_parent) subs in + let subs = List.filter_map (read_with_constraint env parent label_parent) subs in match Odoc_model.Lang.umty_of_mty body with | Some w_expr -> With {w_substitutions=subs; w_expansion=None; w_expr } diff --git a/src/loader/ident_env.ml b/src/loader/ident_env.ml index 3dd81576c8..b52647e6a4 100644 --- a/src/loader/ident_env.ml +++ b/src/loader/ident_env.ml @@ -311,7 +311,7 @@ let rec read_pattern hide_item pat = #if OCAML_VERSION < (5,2,0) | Tpat_var(id, loc) -> #elif defined OXCAML - | Tpat_var(id, loc, _, _, _) -> + | Tpat_var { id; name = loc; _ } -> #else | Tpat_var(id, loc, _) -> #endif @@ -319,7 +319,7 @@ let rec read_pattern hide_item pat = #if OCAML_VERSION < (5,2,0) | Tpat_alias(pat, id, loc) -> #elif defined OXCAML - | Tpat_alias(pat, id, loc, _, _, _, _) -> + | Tpat_alias { pattern = pat; id; name = loc; _ } -> #elif OCAML_VERSION < (5,4,0) | Tpat_alias(pat, id, loc, _) -> #else @@ -367,6 +367,7 @@ let rec read_pattern hide_item pat = #if defined OXCAML | Tpat_unboxed_unit -> [] | Tpat_unboxed_bool _ -> [] + | Tpat_fun_layout _ -> [] #endif let rec extract_structure_tree_items : bool -> Typedtree.structure_item list -> items list = fun hide_item items -> diff --git a/src/loader/odoc_loader.ml b/src/loader/odoc_loader.ml index 696cdb37b8..002e2d0489 100644 --- a/src/loader/odoc_loader.ml +++ b/src/loader/odoc_loader.ml @@ -243,7 +243,11 @@ let read_cmi ~make_root ~parent ~filename ~warnings_tag () = let name = name |> name_to_string in let id, sg = Cmi.read_interface parent name ~warnings_tag +#if defined OXCAML + (Odoc_model.Compat.signature (fst cmi_info.cmi_sign)) +#else (Odoc_model.Compat.signature cmi_info.cmi_sign) +#endif in #if defined OXCAML let imports = diff --git a/src/loader/typedtree_traverse.ml b/src/loader/typedtree_traverse.ml index e57e08047e..54f2d45271 100644 --- a/src/loader/typedtree_traverse.ml +++ b/src/loader/typedtree_traverse.ml @@ -14,7 +14,7 @@ module Analysis = struct else match expr.exp_desc with #if defined OXCAML - | Texp_ident (p, _, _, _, _, _) -> + | Texp_ident { path = p; _ } -> #else | Texp_ident (p, _, _) -> #endif @@ -31,7 +31,7 @@ module Analysis = struct let () = match pat_desc with #if defined OXCAML - | Tpat_var (id, loc, _uid, _, _) -> ( + | Tpat_var { id; name = loc; _ } -> ( #elif OCAML_VERSION >= (5, 2, 0) | Tpat_var (id, loc, _uid) -> ( #else @@ -41,7 +41,7 @@ module Analysis = struct | Some x -> poses := x :: !poses | None -> ()) #if defined OXCAML - | Tpat_alias (_, id, loc, _uid, _, _, _) -> ( + | Tpat_alias { id; name = loc; _ } -> ( #elif OCAML_VERSION >= (5, 4, 0) | Tpat_alias (_, id, loc, _uid, _ty) -> ( #elif OCAML_VERSION >= (5, 2, 0) diff --git a/src/syntax_highlighter/syntax_highlighter.ml b/src/syntax_highlighter/syntax_highlighter.ml index 7145eda73c..e4f322eee7 100644 --- a/src/syntax_highlighter/syntax_highlighter.ml +++ b/src/syntax_highlighter/syntax_highlighter.ml @@ -145,15 +145,14 @@ let tag_of_token (tok : Parser.token) = | HASH_SUFFIX -> "HASH_SUFFIX" | KIND -> "KIND" | KIND_OF -> "KIND_OF" + | LAYOUT -> "LAYOUT" | LBRACKETCOLON -> "LBRACKETCOLON" | LESSLBRACKET -> "LESSLBRACKET" | LOCAL -> "LOCAL" | MOD -> "MOD" - | ONCE -> "ONCE" | OVERWRITE -> "OVERWRITE" | RBRACKETGREATER -> "RBRACKETGREATER" | STACK -> "STACK" - | UNIQUE -> "UNIQUE" #endif #if OCAML_VERSION >= (5,3,0) | METAOCAML_ESCAPE -> "METAOCAML_ESCAPE" diff --git a/test/xref2/lib/common.cppo.ml b/test/xref2/lib/common.cppo.ml index bc41ab9f0d..3cc3a1dd37 100644 --- a/test/xref2/lib/common.cppo.ml +++ b/test/xref2/lib/common.cppo.ml @@ -617,16 +617,23 @@ let my_compilation_unit id (s : Odoc_model.Lang.Signature.t) = } let mkresolver () = - Odoc_odoc.Resolver.create - ~roots:None ~important_digests:false - ~directories:(List.map Odoc_odoc.Fs.Directory.of_string -#if OCAML_VERSION >= (5,2,0) - (let paths = Load_path.get_paths () in - List.filter (fun s -> s <> "") (paths.visible @ paths.hidden)) -#else - (Load_path.get_paths () |> List.filter (fun s -> s <> "")) + let str_dirs = +#if defined OXCAML + let paths = Load_path.get_paths () in + let visible = List.map (fun (v : Clflags.visible_include) -> v.path) paths.visible in + visible @ paths.hidden +#elif OCAML_VERSION >= (5,2,0) + let paths = Load_path.get_paths () in + paths.visible @ paths.hidden +#else + Load_path.get_paths () #endif - ) ~open_modules:[] + in + let nonempty_str_dirs = List.filter (fun s -> s <> "") str_dirs in + let directories = List.map Odoc_odoc.Fs.Directory.of_string nonempty_str_dirs in + Odoc_odoc.Resolver.create + ~roots:None ~important_digests:false + ~directories ~open_modules:[] let warnings_options = { Odoc_model.Error.warn_error = false; print_warnings = true; warnings_tag = None }