You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
```ocaml
# let pp f x = Format.fprintf f "[%s]" x;;
# #install_printer pp;;
# "hi";;
```
On OCaml 4.14 it works:
```ocaml
# let pp f x = Format.fprintf f "[%s]" x;;
val pp : Format.formatter -> string -> unit = <fun>
# #install_printer pp;;
# "hi";;
- : string = [hi]
```
but on 5.0.0 I get an error:
```ocaml
# let pp f x = Format.fprintf f "[%s]" x;;
val pp : Format.formatter -> string -> unit = <fun>
# #install_printer pp;;
Cannot find type Topdirs.printer_type_new.
# "hi";;
- : string = "hi"
```
It works in the OCaml 5 toplevel itself:
$ ocaml
OCaml version 5.0.0
Enter #help;; for help.
# let pp f x = Format.fprintf f "[%s]" x;;
val pp : Format.formatter -> string -> unit = <fun>
# #install_printer pp;;
# "hi";;
- : string = [hi]
The text was updated successfully, but these errors were encountered:
I first thought it is due to the way we patch the printers in 19095a9 but it seems we only do that < 4.14 so there is something else going on here. Will need to investigate where the Topdirs.printer_type_new comes from.
I seem to be able to get this to work by including compiler-libs.toplevel in the libraries field of the mdx stanza. I'm not quite sure why, maybe something related to ocaml/ocaml#11745 but I'm not sure.
The relevant PR for 5.0.0 is probably more ocaml/ocaml#11199: In brief, REPLs that want to install printers need to call Topcommon.load_topdirs_signature () in 5.0.0. Normally, ocaml/ocaml#11745 will solve this issue by removing completely the need to read Topdirs.printer_type_new in 5.1 .
Testing with this input:
On OCaml 4.14 it works:
but on 5.0.0 I get an error:
It works in the OCaml 5 toplevel itself:
The text was updated successfully, but these errors were encountered: