commit
f9b5ec7266
|
@ -1,3 +1,8 @@
|
||||||
|
Unreleased
|
||||||
|
----------
|
||||||
|
|
||||||
|
* Bump the compatibility to 4.08+ (#393 @emillon)
|
||||||
|
|
||||||
2.10.0 (2022-10-06)
|
2.10.0 (2022-10-06)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
|
@ -204,10 +204,7 @@ let discard_formatters pps f =
|
||||||
(* Output functions. *)
|
(* Output functions. *)
|
||||||
let out_functions = {
|
let out_functions = {
|
||||||
Format.out_string = (fun _ _ _ -> ()); out_flush = ignore;
|
Format.out_string = (fun _ _ _ -> ()); out_flush = ignore;
|
||||||
out_newline = ignore; out_spaces = ignore
|
out_newline = ignore; out_spaces = ignore ; out_indent = ignore
|
||||||
#if OCAML_VERSION >= (4, 06, 0)
|
|
||||||
; out_indent = ignore
|
|
||||||
#endif
|
|
||||||
} in
|
} in
|
||||||
(* Replace formatter functions. *)
|
(* Replace formatter functions. *)
|
||||||
List.iter (fun pp -> Format.pp_set_formatter_out_functions pp out_functions) pps;
|
List.iter (fun pp -> Format.pp_set_formatter_out_functions pp out_functions) pps;
|
||||||
|
@ -270,14 +267,10 @@ let parse_default parse str eos_is_error =
|
||||||
(* If the string is empty, do not report an error. *)
|
(* If the string is empty, do not report an error. *)
|
||||||
raise Need_more
|
raise Need_more
|
||||||
| Lexer.Error (error, loc) ->
|
| Lexer.Error (error, loc) ->
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
(match Location.error_of_exn (Lexer.Error (error, loc)) with
|
(match Location.error_of_exn (Lexer.Error (error, loc)) with
|
||||||
| Some (`Ok error)->
|
| Some (`Ok error)->
|
||||||
Error ([mkloc loc], get_message Location.print_report error)
|
Error ([mkloc loc], get_message Location.print_report error)
|
||||||
| _-> raise Need_more)
|
| _-> raise Need_more)
|
||||||
#else
|
|
||||||
Error ([mkloc loc], get_message Lexer.report_error error)
|
|
||||||
#endif
|
|
||||||
| Syntaxerr.Error error -> begin
|
| Syntaxerr.Error error -> begin
|
||||||
match error with
|
match error with
|
||||||
| Syntaxerr.Unclosed (opening_loc, opening, closing_loc, closing) ->
|
| Syntaxerr.Unclosed (opening_loc, opening, closing_loc, closing) ->
|
||||||
|
@ -301,11 +294,9 @@ let parse_default parse str eos_is_error =
|
||||||
| Syntaxerr.Ill_formed_ast (loc, s) ->
|
| Syntaxerr.Ill_formed_ast (loc, s) ->
|
||||||
Error ([mkloc loc],
|
Error ([mkloc loc],
|
||||||
Printf.sprintf "Error: broken invariant in parsetree: %s" s)
|
Printf.sprintf "Error: broken invariant in parsetree: %s" s)
|
||||||
#if OCAML_VERSION >= (4, 03, 0)
|
|
||||||
| Syntaxerr.Invalid_package_type (loc, s) ->
|
| Syntaxerr.Invalid_package_type (loc, s) ->
|
||||||
Error ([mkloc loc],
|
Error ([mkloc loc],
|
||||||
Printf.sprintf "Invalid package type: %s" s)
|
Printf.sprintf "Invalid package type: %s" s)
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (5, 0, 0)
|
#if OCAML_VERSION >= (5, 0, 0)
|
||||||
| Syntaxerr.Removed_string_set loc ->
|
| Syntaxerr.Removed_string_set loc ->
|
||||||
Error ([mkloc loc],
|
Error ([mkloc loc],
|
||||||
|
@ -345,12 +336,6 @@ let with_loc loc str = {
|
||||||
Location.loc = loc;
|
Location.loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 03, 0)
|
|
||||||
let nolabel = Asttypes.Nolabel
|
|
||||||
#else
|
|
||||||
let nolabel = ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(* Check that the given phrase can be evaluated without typing/compile
|
(* Check that the given phrase can be evaluated without typing/compile
|
||||||
errors. *)
|
errors. *)
|
||||||
let check_phrase phrase =
|
let check_phrase phrase =
|
||||||
|
@ -377,7 +362,7 @@ let check_phrase phrase =
|
||||||
with_default_loc loc
|
with_default_loc loc
|
||||||
(fun () ->
|
(fun () ->
|
||||||
Str.eval
|
Str.eval
|
||||||
(Exp.fun_ nolabel None (Pat.construct unit None)
|
(Exp.fun_ Nolabel None (Pat.construct unit None)
|
||||||
(Exp.letmodule (with_loc loc
|
(Exp.letmodule (with_loc loc
|
||||||
#if OCAML_VERSION >= (4, 10, 0)
|
#if OCAML_VERSION >= (4, 10, 0)
|
||||||
(Some "_")
|
(Some "_")
|
||||||
|
@ -810,17 +795,9 @@ let () =
|
||||||
| Backports |
|
| Backports |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
|
||||||
|
|
||||||
let try_finally ~always work=
|
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
Misc.try_finally ~always work
|
|
||||||
#else
|
|
||||||
Misc.try_finally work always
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let use_output command =
|
let use_output command =
|
||||||
let fn = Filename.temp_file "ocaml" "_toploop.ml" in
|
let fn = Filename.temp_file "ocaml" "_toploop.ml" in
|
||||||
try_finally ~always:(fun () ->
|
Misc.try_finally ~always:(fun () ->
|
||||||
try Sys.remove fn with Sys_error _ -> ())
|
try Sys.remove fn with Sys_error _ -> ())
|
||||||
(fun () ->
|
(fun () ->
|
||||||
match
|
match
|
||||||
|
@ -860,7 +837,6 @@ let () =
|
||||||
| Compiler-libs re-exports |
|
| Compiler-libs re-exports |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let get_load_path () = Load_path.get_paths ()
|
let get_load_path () = Load_path.get_paths ()
|
||||||
#if OCAML_VERSION >= (5, 0, 0)
|
#if OCAML_VERSION >= (5, 0, 0)
|
||||||
let set_load_path path =
|
let set_load_path path =
|
||||||
|
@ -868,10 +844,6 @@ let set_load_path path =
|
||||||
#else
|
#else
|
||||||
let set_load_path path = Load_path.init path
|
let set_load_path path = Load_path.init path
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
let get_load_path () = !Config.load_path
|
|
||||||
let set_load_path path = Config.load_path := path
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
| Deprecated |
|
| Deprecated |
|
||||||
|
|
|
@ -414,11 +414,7 @@ let visible_modules () =
|
||||||
(Sys.readdir (if dir = "" then Filename.current_dir_name else dir))
|
(Sys.readdir (if dir = "" then Filename.current_dir_name else dir))
|
||||||
with Sys_error _ ->
|
with Sys_error _ ->
|
||||||
acc)
|
acc)
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
String_set.empty @@ Load_path.get_paths ()
|
String_set.empty @@ Load_path.get_paths ()
|
||||||
#else
|
|
||||||
String_set.empty !Config.load_path
|
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
|
|
||||||
let field_name { ld_id = id } = Ident.name id
|
let field_name { ld_id = id } = Ident.name id
|
||||||
|
@ -454,45 +450,22 @@ let add_names_of_type decl acc =
|
||||||
| Type_open ->
|
| Type_open ->
|
||||||
acc
|
acc
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let path_of_mty_alias = function
|
let path_of_mty_alias = function
|
||||||
| Mty_alias path -> path
|
| Mty_alias path -> path
|
||||||
| _ -> assert false
|
| _ -> assert false
|
||||||
#elif OCAML_VERSION >= (4, 04, 0)
|
|
||||||
let path_of_mty_alias = function
|
|
||||||
| Mty_alias (_, path) -> path
|
|
||||||
| _ -> assert false
|
|
||||||
#else
|
|
||||||
let path_of_mty_alias = function
|
|
||||||
| Mty_alias path -> path
|
|
||||||
| _ -> assert false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let rec names_of_module_type = function
|
let rec names_of_module_type = function
|
||||||
| Mty_signature decls ->
|
| Mty_signature decls ->
|
||||||
List.fold_left
|
List.fold_left
|
||||||
(fun acc decl -> match decl with
|
(fun acc decl -> match decl with
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Sig_value (id, _, _)
|
| Sig_value (id, _, _)
|
||||||
| Sig_typext (id, _, _, _)
|
| Sig_typext (id, _, _, _)
|
||||||
| Sig_module (id, _, _, _, _)
|
| Sig_module (id, _, _, _, _)
|
||||||
| Sig_modtype (id, _, _)
|
| Sig_modtype (id, _, _)
|
||||||
| Sig_class (id, _, _, _)
|
| Sig_class (id, _, _, _)
|
||||||
| Sig_class_type (id, _, _, _) ->
|
| Sig_class_type (id, _, _, _) ->
|
||||||
#else
|
|
||||||
| Sig_value (id, _)
|
|
||||||
| Sig_typext (id, _, _)
|
|
||||||
| Sig_module (id, _, _)
|
|
||||||
| Sig_modtype (id, _)
|
|
||||||
| Sig_class (id, _, _)
|
|
||||||
| Sig_class_type (id, _, _) ->
|
|
||||||
#endif
|
|
||||||
add (Ident.name id) acc
|
add (Ident.name id) acc
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Sig_type (id, decl, _, _) ->
|
| Sig_type (id, decl, _, _) ->
|
||||||
#else
|
|
||||||
| Sig_type (id, decl, _) ->
|
|
||||||
#endif
|
|
||||||
add_names_of_type decl (add (Ident.name id) acc))
|
add_names_of_type decl (add (Ident.name id) acc))
|
||||||
String_set.empty decls
|
String_set.empty decls
|
||||||
| Mty_ident path -> begin
|
| Mty_ident path -> begin
|
||||||
|
@ -521,11 +494,7 @@ let rec fields_of_module_type = function
|
||||||
| Sig_class _
|
| Sig_class _
|
||||||
| Sig_class_type _ ->
|
| Sig_class_type _ ->
|
||||||
acc
|
acc
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Sig_type (_, decl, _, _) ->
|
| Sig_type (_, decl, _, _) ->
|
||||||
#else
|
|
||||||
| Sig_type (_, decl, _) ->
|
|
||||||
#endif
|
|
||||||
add_fields_of_type decl acc)
|
add_fields_of_type decl acc)
|
||||||
String_set.empty decls
|
String_set.empty decls
|
||||||
| Mty_ident path -> begin
|
| Mty_ident path -> begin
|
||||||
|
@ -595,11 +564,7 @@ let list_global_names () =
|
||||||
loop (add_names_of_type decl (add (Ident.name id) acc)) summary
|
loop (add_names_of_type decl (add (Ident.name id) acc)) summary
|
||||||
| Env.Env_extension(summary, id, _) ->
|
| Env.Env_extension(summary, id, _) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_module(summary, id, _, _) ->
|
| Env.Env_module(summary, id, _, _) ->
|
||||||
#else
|
|
||||||
| Env.Env_module(summary, id, _) ->
|
|
||||||
#endif
|
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
| Env.Env_modtype(summary, id, _) ->
|
| Env.Env_modtype(summary, id, _) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
|
@ -609,28 +574,18 @@ let list_global_names () =
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
| Env.Env_functor_arg(summary, id) ->
|
| Env.Env_functor_arg(summary, id) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_persistent (summary, id) ->
|
| Env.Env_persistent (summary, id) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (4, 04, 0)
|
|
||||||
| Env.Env_constraints (summary, _) ->
|
| Env.Env_constraints (summary, _) ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (4, 10, 0)
|
#if OCAML_VERSION >= (4, 10, 0)
|
||||||
| Env.Env_copy_types summary ->
|
| Env.Env_copy_types summary ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#elif OCAML_VERSION >= (4, 06, 0)
|
#else
|
||||||
| Env.Env_copy_types (summary, _) ->
|
| Env.Env_copy_types (summary, _) ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#endif
|
#endif
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_open(summary, path) ->
|
| Env.Env_open(summary, path) ->
|
||||||
#elif OCAML_VERSION >= (4, 07, 0)
|
|
||||||
| Env.Env_open(summary, _, path) ->
|
|
||||||
#else
|
|
||||||
| Env.Env_open(summary, path) ->
|
|
||||||
#endif
|
|
||||||
match try Some (Path_map.find path !local_names_by_path) with Not_found -> None with
|
match try Some (Path_map.find path !local_names_by_path) with Not_found -> None with
|
||||||
| Some names ->
|
| Some names ->
|
||||||
loop (String_set.union acc names) summary
|
loop (String_set.union acc names) summary
|
||||||
|
@ -670,11 +625,7 @@ let list_global_fields () =
|
||||||
loop (add_fields_of_type decl (add (Ident.name id) acc)) summary
|
loop (add_fields_of_type decl (add (Ident.name id) acc)) summary
|
||||||
| Env.Env_extension(summary, id, _) ->
|
| Env.Env_extension(summary, id, _) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_module(summary, id, _, _) ->
|
| Env.Env_module(summary, id, _, _) ->
|
||||||
#else
|
|
||||||
| Env.Env_module(summary, id, _) ->
|
|
||||||
#endif
|
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
| Env.Env_functor_arg(summary, id) ->
|
| Env.Env_functor_arg(summary, id) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
|
@ -684,30 +635,18 @@ let list_global_fields () =
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
| Env.Env_cltype(summary, id, _) ->
|
| Env.Env_cltype(summary, id, _) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_persistent (summary, id) ->
|
| Env.Env_persistent (summary, id) ->
|
||||||
loop (add (Ident.name id) acc) summary
|
loop (add (Ident.name id) acc) summary
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (4, 04, 0)
|
|
||||||
| Env.Env_constraints (summary, _) ->
|
| Env.Env_constraints (summary, _) ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (4, 10, 0)
|
#if OCAML_VERSION >= (4, 10, 0)
|
||||||
| Env.Env_copy_types summary ->
|
| Env.Env_copy_types summary ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#elif OCAML_VERSION >= (4, 06, 0)
|
#else
|
||||||
| Env.Env_copy_types (summary, _) ->
|
| Env.Env_copy_types (summary, _) ->
|
||||||
loop acc summary
|
loop acc summary
|
||||||
#endif
|
#endif
|
||||||
#if OCAML_VERSION >= (4, 07, 0)
|
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Env.Env_open(summary, path) ->
|
| Env.Env_open(summary, path) ->
|
||||||
#else
|
|
||||||
| Env.Env_open(summary, _, path) ->
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
| Env.Env_open(summary, path) ->
|
|
||||||
#endif
|
|
||||||
match try Some (Path_map.find path !local_fields_by_path) with Not_found -> None with
|
match try Some (Path_map.find path !local_fields_by_path) with Not_found -> None with
|
||||||
| Some fields ->
|
| Some fields ->
|
||||||
loop (String_set.union acc fields) summary
|
loop (String_set.union acc fields) summary
|
||||||
|
@ -817,14 +756,6 @@ let rec labels_of_type acc type_expr =
|
||||||
| Tpoly (te, _) ->
|
| Tpoly (te, _) ->
|
||||||
labels_of_type acc te
|
labels_of_type acc te
|
||||||
| Tarrow(label, _, te, _) ->
|
| Tarrow(label, _, te, _) ->
|
||||||
#if OCAML_VERSION < (4, 03, 0)
|
|
||||||
if label = "" then
|
|
||||||
labels_of_type acc te
|
|
||||||
else if label.[0] = '?' then
|
|
||||||
labels_of_type (String_map.add (String.sub label 1 (String.length label - 1)) Optional acc) te
|
|
||||||
else
|
|
||||||
labels_of_type (String_map.add label Required acc) te
|
|
||||||
#else
|
|
||||||
(match label with
|
(match label with
|
||||||
| Nolabel ->
|
| Nolabel ->
|
||||||
labels_of_type acc te
|
labels_of_type acc te
|
||||||
|
@ -832,7 +763,6 @@ let rec labels_of_type acc type_expr =
|
||||||
labels_of_type (String_map.add label Optional acc) te
|
labels_of_type (String_map.add label Optional acc) te
|
||||||
| Labelled label ->
|
| Labelled label ->
|
||||||
labels_of_type (String_map.add label Required acc) te)
|
labels_of_type (String_map.add label Required acc) te)
|
||||||
#endif
|
|
||||||
| Tconstr(path, _, _) -> begin
|
| Tconstr(path, _, _) -> begin
|
||||||
match lookup_env Env.find_type path !Toploop.toplevel_env with
|
match lookup_env Env.find_type path !Toploop.toplevel_env with
|
||||||
| None
|
| None
|
||||||
|
@ -985,11 +915,7 @@ let complete ~phrase_terminator ~input =
|
||||||
(fun acc d -> add_files filter acc (Filename.concat d dir))
|
(fun acc d -> add_files filter acc (Filename.concat d dir))
|
||||||
String_map.empty
|
String_map.empty
|
||||||
(Filename.current_dir_name ::
|
(Filename.current_dir_name ::
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
(Load_path.get_paths ())
|
(Load_path.get_paths ())
|
||||||
#else
|
|
||||||
!Config.load_path
|
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1049,11 +975,7 @@ let complete ~phrase_terminator ~input =
|
||||||
(fun acc d -> add_files filter acc (Filename.concat d dir))
|
(fun acc d -> add_files filter acc (Filename.concat d dir))
|
||||||
String_map.empty
|
String_map.empty
|
||||||
(Filename.current_dir_name ::
|
(Filename.current_dir_name ::
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
(Load_path.get_paths ())
|
(Load_path.get_paths ())
|
||||||
#else
|
|
||||||
!Config.load_path
|
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
add_files filter String_map.empty (Filename.dirname file)
|
add_files filter String_map.empty (Filename.dirname file)
|
||||||
|
|
|
@ -130,17 +130,11 @@ let convert_loc_line input locs lines =
|
||||||
| The read-line class |
|
| The read-line class |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 04, 0)
|
|
||||||
let ast_impl_kind = Pparse.Structure
|
|
||||||
#else
|
|
||||||
let ast_impl_kind = Config.ast_impl_magic_number
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let preprocess input =
|
let preprocess input =
|
||||||
match input with
|
match input with
|
||||||
| Parsetree.Ptop_def pstr ->
|
| Parsetree.Ptop_def pstr ->
|
||||||
Parsetree.Ptop_def
|
Parsetree.Ptop_def
|
||||||
(Pparse.apply_rewriters ~tool_name:"ocaml" ast_impl_kind pstr)
|
(Pparse.apply_rewriters ~tool_name:"ocaml" Pparse.Structure pstr)
|
||||||
| _ -> input
|
| _ -> input
|
||||||
|
|
||||||
let parse_input_multi input =
|
let parse_input_multi input =
|
||||||
|
@ -383,14 +377,9 @@ let map_items unwrap wrap items =
|
||||||
(name, rs)
|
(name, rs)
|
||||||
| Outcometree.Osig_typext ({ Outcometree.oext_name = name}, _)
|
| Outcometree.Osig_typext ({ Outcometree.oext_name = name}, _)
|
||||||
| Outcometree.Osig_modtype (name, _)
|
| Outcometree.Osig_modtype (name, _)
|
||||||
#if OCAML_VERSION < (4, 03, 0)
|
|
||||||
| Outcometree.Osig_value (name, _, _) ->
|
|
||||||
(name, Outcometree.Orec_not)
|
|
||||||
#else
|
|
||||||
| Outcometree.Osig_value { oval_name = name; _ } ->
|
| Outcometree.Osig_value { oval_name = name; _ } ->
|
||||||
(name, Outcometree.Orec_not)
|
(name, Outcometree.Orec_not)
|
||||||
| Outcometree.Osig_ellipsis -> ("", Outcometree.Orec_not)
|
| Outcometree.Osig_ellipsis -> ("", Outcometree.Orec_not)
|
||||||
#endif
|
|
||||||
in
|
in
|
||||||
let keep =
|
let keep =
|
||||||
name = "" || name.[0] <> '_' ||
|
name = "" || name.[0] <> '_' ||
|
||||||
|
@ -428,9 +417,7 @@ let map_items unwrap wrap items =
|
||||||
else
|
else
|
||||||
items
|
items
|
||||||
| Outcometree.Osig_typext _
|
| Outcometree.Osig_typext _
|
||||||
#if OCAML_VERSION >= (4, 03, 0)
|
|
||||||
| Outcometree.Osig_ellipsis
|
| Outcometree.Osig_ellipsis
|
||||||
#endif
|
|
||||||
| Outcometree.Osig_modtype _
|
| Outcometree.Osig_modtype _
|
||||||
| Outcometree.Osig_value _ ->
|
| Outcometree.Osig_value _ ->
|
||||||
items
|
items
|
||||||
|
@ -497,12 +484,6 @@ let longident_async_thread_safe_block_on_async_exn =
|
||||||
Longident.(Ldot (Ldot (Lident "Async", "Thread_safe"), "block_on_async_exn"))
|
Longident.(Ldot (Ldot (Lident "Async", "Thread_safe"), "block_on_async_exn"))
|
||||||
let longident_unit = Longident.Lident "()"
|
let longident_unit = Longident.Lident "()"
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 03, 0)
|
|
||||||
let nolabel = Asttypes.Nolabel
|
|
||||||
#else
|
|
||||||
let nolabel = ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let rewrite_rules = [
|
let rewrite_rules = [
|
||||||
(* Rewrite Lwt.t expressions to Lwt_main.run <expr> *)
|
(* Rewrite Lwt.t expressions to Lwt_main.run <expr> *)
|
||||||
{
|
{
|
||||||
|
@ -512,7 +493,7 @@ let rewrite_rules = [
|
||||||
rewrite = (fun loc e ->
|
rewrite = (fun loc e ->
|
||||||
let open Ast_helper in
|
let open Ast_helper in
|
||||||
with_default_loc loc (fun () ->
|
with_default_loc loc (fun () ->
|
||||||
Exp.apply (Exp.ident (with_loc loc longident_lwt_main_run)) [(nolabel, e)]
|
Exp.apply (Exp.ident (with_loc loc longident_lwt_main_run)) [(Nolabel, e)]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
enabled = UTop.auto_run_lwt;
|
enabled = UTop.auto_run_lwt;
|
||||||
|
@ -530,7 +511,7 @@ let rewrite_rules = [
|
||||||
with_default_loc loc (fun () ->
|
with_default_loc loc (fun () ->
|
||||||
Exp.apply
|
Exp.apply
|
||||||
(Exp.ident (with_loc loc longident_async_thread_safe_block_on_async_exn))
|
(Exp.ident (with_loc loc longident_async_thread_safe_block_on_async_exn))
|
||||||
[(nolabel, Exp.fun_ nolabel None punit e)]
|
[(Nolabel, Exp.fun_ Nolabel None punit e)]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
enabled = UTop.auto_run_async;
|
enabled = UTop.auto_run_async;
|
||||||
|
@ -540,12 +521,10 @@ let rewrite_rules = [
|
||||||
#if OCAML_VERSION >= (4, 10, 0)
|
#if OCAML_VERSION >= (4, 10, 0)
|
||||||
let lookup_type longident env =
|
let lookup_type longident env =
|
||||||
Env.find_type_by_name longident env
|
Env.find_type_by_name longident env
|
||||||
#elif OCAML_VERSION >= (4, 04, 0)
|
#else
|
||||||
let lookup_type longident env =
|
let lookup_type longident env =
|
||||||
let path = Env.lookup_type longident env in
|
let path = Env.lookup_type longident env in
|
||||||
(path, Env.find_type path env)
|
(path, Env.find_type path env)
|
||||||
#else
|
|
||||||
let lookup_type = Env.lookup_type
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
let rule_path rule =
|
let rule_path rule =
|
||||||
|
@ -575,11 +554,7 @@ let rule_path rule =
|
||||||
(* Returns whether the given path is persistent. *)
|
(* Returns whether the given path is persistent. *)
|
||||||
let rec is_persistent_path = function
|
let rec is_persistent_path = function
|
||||||
| Path.Pident id -> Ident.persistent id
|
| Path.Pident id -> Ident.persistent id
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Path.Pdot (p, _) -> is_persistent_path p
|
| Path.Pdot (p, _) -> is_persistent_path p
|
||||||
#else
|
|
||||||
| Path.Pdot (p, _, _) -> is_persistent_path p
|
|
||||||
#endif
|
|
||||||
| Path.Papply (_, p) -> is_persistent_path p
|
| Path.Papply (_, p) -> is_persistent_path p
|
||||||
|
|
||||||
(* Check that the given long identifier is present in the environment
|
(* Check that the given long identifier is present in the environment
|
||||||
|
@ -641,10 +616,8 @@ let type_structure env pstr =
|
||||||
let tstr, _, _, _, _ = Typemod.type_structure env pstr in
|
let tstr, _, _, _, _ = Typemod.type_structure env pstr in
|
||||||
#elif OCAML_VERSION >= (4, 12, 0)
|
#elif OCAML_VERSION >= (4, 12, 0)
|
||||||
let tstr, _, _, _ = Typemod.type_structure env pstr in
|
let tstr, _, _, _ = Typemod.type_structure env pstr in
|
||||||
#elif OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let tstr, _, _, _ = Typemod.type_structure env pstr Location.none in
|
|
||||||
#else
|
#else
|
||||||
let tstr, _, _ = Typemod.type_structure env pstr Location.none in
|
let tstr, _, _, _ = Typemod.type_structure env pstr Location.none in
|
||||||
#endif
|
#endif
|
||||||
tstr
|
tstr
|
||||||
|
|
||||||
|
@ -669,9 +642,7 @@ let add_let binding_name def =
|
||||||
{
|
{
|
||||||
pvb_pat = {
|
pvb_pat = {
|
||||||
ppat_desc = Ppat_var { txt = binding_name; loc = pstr_loc; };
|
ppat_desc = Ppat_var { txt = binding_name; loc = pstr_loc; };
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
ppat_loc_stack= [];
|
ppat_loc_stack= [];
|
||||||
#endif
|
|
||||||
ppat_loc = pstr_loc;
|
ppat_loc = pstr_loc;
|
||||||
ppat_attributes = [];
|
ppat_attributes = [];
|
||||||
};
|
};
|
||||||
|
@ -694,8 +665,6 @@ let bind_expressions name phrase =
|
||||||
| Handling of [@@toplevel_printer] attributes |
|
| Handling of [@@toplevel_printer] attributes |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 04, 0)
|
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 09, 0)
|
#if OCAML_VERSION >= (4, 09, 0)
|
||||||
module Persistent_signature = Persistent_env.Persistent_signature
|
module Persistent_signature = Persistent_env.Persistent_signature
|
||||||
#else
|
#else
|
||||||
|
@ -715,27 +684,13 @@ let execute_phrase =
|
||||||
let rec collect_printers path signature acc =
|
let rec collect_printers path signature acc =
|
||||||
List.fold_left (fun acc item ->
|
List.fold_left (fun acc item ->
|
||||||
match (item : Types.signature_item) with
|
match (item : Types.signature_item) with
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Sig_module (id, _, {md_type = Mty_signature s; _}, _, _) ->
|
| Sig_module (id, _, {md_type = Mty_signature s; _}, _, _) ->
|
||||||
#else
|
|
||||||
| Sig_module (id, {md_type = Mty_signature s; _}, _) ->
|
|
||||||
#endif
|
|
||||||
collect_printers (Longident.Ldot (path, Ident.name id)) s acc
|
collect_printers (Longident.Ldot (path, Ident.name id)) s acc
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
| Sig_value (id, vd, _) ->
|
| Sig_value (id, vd, _) ->
|
||||||
#else
|
|
||||||
| Sig_value (id, vd) ->
|
|
||||||
#endif
|
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
if List.exists (fun attr->
|
if List.exists (fun attr->
|
||||||
let open Parsetree in
|
let open Parsetree in
|
||||||
match attr.attr_name with
|
match attr.attr_name with
|
||||||
| {Asttypes.txt = "toplevel_printer" | "ocaml.toplevel_printer"; _} ->
|
| {Asttypes.txt = "toplevel_printer" | "ocaml.toplevel_printer"; _} ->
|
||||||
#else
|
|
||||||
if List.exists (function
|
|
||||||
| {Asttypes.txt = "toplevel_printer" | "ocaml.toplevel_printer"; _},
|
|
||||||
_ ->
|
|
||||||
#endif
|
|
||||||
true
|
true
|
||||||
| _ -> false)
|
| _ -> false)
|
||||||
vd.val_attributes
|
vd.val_attributes
|
||||||
|
@ -763,12 +718,6 @@ let execute_phrase =
|
||||||
acknowledge_new_cmis ();
|
acknowledge_new_cmis ();
|
||||||
res
|
res
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
let execute_phrase = Toploop.execute_phrase
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
| Main loop |
|
| Main loop |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
@ -1278,48 +1227,28 @@ let typeof sid =
|
||||||
let out_sig_item =
|
let out_sig_item =
|
||||||
try
|
try
|
||||||
let (path, ty_decl) = lookup_type id env in
|
let (path, ty_decl) = lookup_type id env in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
try
|
try
|
||||||
let (path, val_descr) = lookup_value id env in
|
let (path, val_descr) = lookup_value id env in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_value_description id val_descr)
|
Some (Printtyp.tree_of_value_description id val_descr)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
try
|
try
|
||||||
let lbl_desc = lookup_label id env in
|
let lbl_desc = lookup_label id env in
|
||||||
let (path, ty_decl) = from_type_desc (get_desc lbl_desc.Types.lbl_res) in
|
let (path, ty_decl) = from_type_desc (get_desc lbl_desc.Types.lbl_res) in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
try
|
try
|
||||||
let path, mod_typ = lookup_module id env in
|
let path, mod_typ = lookup_module id env in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_module id mod_typ Types.Trec_not)
|
Some (Printtyp.tree_of_module id mod_typ Types.Trec_not)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
try
|
try
|
||||||
let (path, mty_decl) = lookup_modtype id env in
|
let (path, mty_decl) = lookup_modtype id env in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_modtype_declaration id mty_decl)
|
Some (Printtyp.tree_of_modtype_declaration id mty_decl)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
try
|
try
|
||||||
|
@ -1331,11 +1260,7 @@ let typeof sid =
|
||||||
match cstr_desc.Types.cstr_tag with
|
match cstr_desc.Types.cstr_tag with
|
||||||
| _ ->
|
| _ ->
|
||||||
let (path, ty_decl) = from_type_desc (get_desc cstr_desc.Types.cstr_res) in
|
let (path, ty_decl) = from_type_desc (get_desc cstr_desc.Types.cstr_res) in
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
let id = Ident.create_local (Path.name path) in
|
let id = Ident.create_local (Path.name path) in
|
||||||
#else
|
|
||||||
let id = Ident.create (Path.name path) in
|
|
||||||
#endif
|
|
||||||
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
Some (Printtyp.tree_of_type_declaration id ty_decl Types.Trec_not)
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
None
|
None
|
||||||
|
@ -1445,11 +1370,7 @@ let print_version_num () =
|
||||||
let autoload = ref true
|
let autoload = ref true
|
||||||
|
|
||||||
let args = Arg.align [
|
let args = Arg.align [
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
"-absname", Arg.Set Clflags.absname, " Show absolute filenames in error message";
|
"-absname", Arg.Set Clflags.absname, " Show absolute filenames in error message";
|
||||||
#else
|
|
||||||
"-absname", Arg.Set Location.absname, " Show absolute filenames in error message";
|
|
||||||
#endif
|
|
||||||
"-I", Arg.String (fun dir -> Clflags.include_dirs := dir :: !Clflags.include_dirs), "<dir> Add <dir> to the list of include directories";
|
"-I", Arg.String (fun dir -> Clflags.include_dirs := dir :: !Clflags.include_dirs), "<dir> Add <dir> to the list of include directories";
|
||||||
"-init", Arg.String (fun s -> Clflags.init_file := Some s), "<file> Load <file> instead of default init file";
|
"-init", Arg.String (fun s -> Clflags.init_file := Some s), "<file> Load <file> instead of default init file";
|
||||||
"-labels", Arg.Clear Clflags.classic, " Use commuting label mode";
|
"-labels", Arg.Clear Clflags.classic, " Use commuting label mode";
|
||||||
|
@ -1467,11 +1388,7 @@ let args = Arg.align [
|
||||||
"-rectypes", Arg.Set Clflags.recursive_types, " Allow arbitrary recursive types";
|
"-rectypes", Arg.Set Clflags.recursive_types, " Allow arbitrary recursive types";
|
||||||
"-stdin", Arg.Unit (fun () -> run_script ""), " Read script from standard input";
|
"-stdin", Arg.Unit (fun () -> run_script ""), " Read script from standard input";
|
||||||
"-strict-sequence", Arg.Set Clflags.strict_sequence, " Left-hand part of a sequence must have type unit";
|
"-strict-sequence", Arg.Set Clflags.strict_sequence, " Left-hand part of a sequence must have type unit";
|
||||||
#if OCAML_VERSION >= (4, 08, 0)
|
|
||||||
"-unsafe", Arg.Set Clflags.unsafe, " Do not compile bounds checking on array and string access";
|
"-unsafe", Arg.Set Clflags.unsafe, " Do not compile bounds checking on array and string access";
|
||||||
#else
|
|
||||||
"-unsafe", Arg.Set Clflags.fast, " Do not compile bounds checking on array and string access";
|
|
||||||
#endif
|
|
||||||
"-version", Arg.Unit print_version, " Print version and exit";
|
"-version", Arg.Unit print_version, " Print version and exit";
|
||||||
"-vnum", Arg.Unit print_version_num, " Print version number and exit";
|
"-vnum", Arg.Unit print_version_num, " Print version number and exit";
|
||||||
"-w", Arg.String (fun opt -> ignore (Warnings.parse_options false opt)),
|
"-w", Arg.String (fun opt -> ignore (Warnings.parse_options false opt)),
|
||||||
|
@ -1665,18 +1582,10 @@ type value = V : string * _ -> value
|
||||||
|
|
||||||
exception Found of Env.t
|
exception Found of Env.t
|
||||||
|
|
||||||
#if OCAML_VERSION >= (4, 03, 0)
|
|
||||||
let get_required_label name args =
|
let get_required_label name args =
|
||||||
match List.find (fun (lab, _) -> lab = Asttypes.Labelled name) args with
|
match List.find (fun (lab, _) -> lab = Asttypes.Labelled name) args with
|
||||||
| _, x -> x
|
| _, x -> x
|
||||||
| exception Not_found -> None
|
| exception Not_found -> None
|
||||||
#else
|
|
||||||
let get_required_label name args =
|
|
||||||
match List.find (fun (lab, _, k) -> lab = "loc" && k = Typedtree.Required) args with
|
|
||||||
| _, x, _ -> x
|
|
||||||
| _ -> None
|
|
||||||
| exception Not_found -> None
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let walk dir ~init ~f =
|
let walk dir ~init ~f =
|
||||||
let rec loop dir acc =
|
let rec loop dir acc =
|
||||||
|
|
|
@ -6,7 +6,7 @@ homepage: "https://github.com/ocaml-community/utop"
|
||||||
bug-reports: "https://github.com/ocaml-community/utop/issues"
|
bug-reports: "https://github.com/ocaml-community/utop/issues"
|
||||||
doc: "https://ocaml-community.github.io/utop/"
|
doc: "https://ocaml-community.github.io/utop/"
|
||||||
depends: [
|
depends: [
|
||||||
"ocaml" {>= "4.03.0"}
|
"ocaml" {>= "4.08.0"}
|
||||||
"base-unix"
|
"base-unix"
|
||||||
"base-threads"
|
"base-threads"
|
||||||
"ocamlfind" {>= "1.7.2"}
|
"ocamlfind" {>= "1.7.2"}
|
||||||
|
|
Loading…
Reference in New Issue