Skip to content

Commit

Permalink
Revert "toplevel: restore toplevel printer installation with ocamlmktop"
Browse files Browse the repository at this point in the history
This reverts commit 8b97bfc.
  • Loading branch information
Octachron committed Jul 4, 2022
1 parent 8b97bfc commit 0efd547
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
2 changes: 0 additions & 2 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -6352,7 +6352,6 @@ toplevel/topdirs.cmo : \
typing/types.cmi \
toplevel/toploop.cmi \
toplevel/topeval.cmi \
toplevel/topcommon.cmi \
typing/printtyp.cmi \
typing/predef.cmi \
typing/path.cmi \
Expand All @@ -6377,7 +6376,6 @@ toplevel/topdirs.cmx : \
typing/types.cmx \
toplevel/toploop.cmx \
toplevel/topeval.cmi \
toplevel/topcommon.cmx \
typing/printtyp.cmx \
typing/predef.cmx \
typing/path.cmx \
Expand Down
36 changes: 10 additions & 26 deletions toplevel/topdirs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -211,34 +211,18 @@ let extract_target_parameters ty =
type 'a printer_type_new = Format.formatter -> 'a -> unit
type 'a printer_type_old = 'a -> unit

let kprinter_type ppf typename on_failure =
match
Env.find_type_by_name
(Ldot(Lident "Topdirs", typename)) !toplevel_env
with
| path, _ -> path
| exception Not_found ->
on_failure ppf typename

let printer_type ppf typename =
let exit_on_failure ppf typename =
fprintf ppf "Cannot find type Topdirs.%s.@." typename;
raise Exit
let printer_type =
match
Env.find_type_by_name
(Ldot(Lident "Topdirs", typename)) !toplevel_env
with
| path, _ -> path
| exception Not_found ->
fprintf ppf "Cannot find type Topdirs.%s.@." typename;
raise Exit
in
let load_topdirs_on_failure ppf typename =
(* The compiled interface "topdirs.cmi" has been moved to +compiler-libs in
OCaml 5.
This creates a backward compatibility issue with ocamlmktop users that
install printers before the toplevel is fully initialized.
To avoid this issue, if we cannot find "Topdirs" in the environment when
trying to install a printer, we try to load +compiler-libs/topdirs.cmi
ourself before failing
*)
Topcommon.load_topdirs_signature ();
kprinter_type ppf typename exit_on_failure
in
kprinter_type ppf typename load_topdirs_on_failure

printer_type

let match_simple_printer_type desc printer_type =
Ctype.begin_def();
Expand Down

0 comments on commit 0efd547

Please sign in to comment.