Skip to content

Commit b490bac

Browse files
authored
Merge pull request #489 from anmonteiro/anmonteiro/ocaml-5.3
OCaml 5.3 support
2 parents 384b309 + c7bab9e commit b490bac

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/lib/uTop_compat.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ let rec is_persistent_path = function
6666
| Path.Pextra_ty (p, _) -> is_persistent_path p
6767
#endif
6868

69+
#if OCAML_VERSION >= (5, 2, 0)
70+
let inline_code =
71+
#if OCAML_VERSION >= (5, 3, 0)
72+
(Format_doc.compat Misc.Style.inline_code)
73+
#else
74+
Misc.Style.inline_code
75+
#endif
76+
#endif
77+
6978
let invalid_package_error_to_string err =
7079
#if OCAML_VERSION >= (5, 2, 0)
7180
(* NOTE: from https://github.com/ocaml/ocaml/blob/9b059b1e7a66e9d2f04d892a4de34c418cd96f69/parsing/parse.ml#L149 *)
@@ -78,11 +87,11 @@ let invalid_package_error_to_string err =
7887
Format.fprintf ppf "private types are not supported"
7988
| Not_with_type ->
8089
Format.fprintf ppf "only %a constraints are supported"
81-
Misc.Style.inline_code "with type t ="
90+
inline_code "with type t ="
8291
| Neither_identifier_nor_with_type ->
8392
Format.fprintf ppf
8493
"only module type identifier and %a constraints are supported"
85-
Misc.Style.inline_code "with type"
94+
inline_code "with type"
8695
in
8796
let buf = Buffer.create 128 in
8897
let fmt = Format.formatter_of_buffer buf in
@@ -119,7 +128,7 @@ let find_in_path_normalized =
119128
Misc.find_in_path_normalized
120129
#else
121130
Misc.find_in_path_uncap
122-
#endif
131+
#endif
123132

124133
let visible_paths_for_cmt_infos (cmt_infos: Cmt_format.cmt_infos) =
125134
#if OCAML_VERSION >= (5, 2, 0)

src/lib/uTop_main.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,13 @@ end
11651165
| Extra macros |
11661166
+-----------------------------------------------------------------+ *)
11671167

1168+
module Printtyp =
1169+
#if OCAML_VERSION >= (5, 3, 0)
1170+
Out_type
1171+
#else
1172+
Printtyp
1173+
#endif
1174+
11681175
let typeof sid =
11691176
let id = Parse.longident (Lexing.from_string sid) in
11701177
let env = !Toploop.toplevel_env in
@@ -1218,7 +1225,11 @@ let typeof sid =
12181225
| Some osig ->
12191226
let buf = Buffer.create 128 in
12201227
let pp = Format.formatter_of_buffer buf in
1228+
#if OCAML_VERSION >= (5, 3, 0)
1229+
Format.fprintf pp "%a" (Format_doc.compat !Toploop.print_out_signature) [osig];
1230+
#else
12211231
!Toploop.print_out_signature pp [osig];
1232+
#endif
12221233
Format.pp_print_newline pp ();
12231234
let str = Buffer.contents buf in
12241235
Lwt_main.run (Lazy.force LTerm.stdout >>= fun term -> render_out_phrase term str)
@@ -1584,6 +1595,10 @@ let () =
15841595
Location.register_error_of_exn
15851596
(function
15861597
| Envaux.Error err ->
1598+
#if OCAML_VERSION >= (5,3,0)
1599+
Some (Location.error_of_printer_file Envaux.report_error_doc err)
1600+
#else
15871601
Some (Location.error_of_printer_file Envaux.report_error err)
1602+
#endif
15881603
| _ -> None
15891604
)

0 commit comments

Comments
 (0)