fix UTop.check_phrase
The [get_ocaml_error_message] was done after the [Btype.backtrack] in case of error, causing the type to be displayed incorrectly.
This commit is contained in:
parent
b721aa054b
commit
589f0707c4
|
@ -307,16 +307,22 @@ let check_phrase phrase =
|
|||
} in
|
||||
let check_phrase = Parsetree.Ptop_def [top_def] in
|
||||
try
|
||||
let _ = discard_formatters [Format.err_formatter] (fun () -> Toploop.execute_phrase false null check_phrase) in
|
||||
let _ =
|
||||
discard_formatters [Format.err_formatter] (fun () ->
|
||||
#if ocaml_version > (4, 00, 1)
|
||||
Env.reset_cache_toplevel ();
|
||||
#endif
|
||||
Toploop.execute_phrase false null check_phrase)
|
||||
in
|
||||
(* The phrase is safe. *)
|
||||
Toploop.toplevel_env := env;
|
||||
Btype.backtrack snap;
|
||||
None
|
||||
with exn ->
|
||||
(* The phrase contains errors. *)
|
||||
let loc, msg = get_ocaml_error_message exn in
|
||||
Toploop.toplevel_env := env;
|
||||
Btype.backtrack snap;
|
||||
let loc, msg = get_ocaml_error_message exn in
|
||||
Some ([loc], msg)
|
||||
|
||||
(* +-----------------------------------------------------------------+
|
||||
|
|
|
@ -538,6 +538,9 @@ let rec loop term =
|
|||
let pp = Format.formatter_of_buffer buffer in
|
||||
Format.pp_set_margin pp (LTerm.size term).cols;
|
||||
(try
|
||||
#if ocaml_version > (4, 00, 1)
|
||||
Env.reset_cache_toplevel ();
|
||||
#endif
|
||||
ignore (Toploop.execute_phrase true pp phrase);
|
||||
(* Flush everything. *)
|
||||
Format.pp_print_flush Format.std_formatter ();
|
||||
|
@ -742,6 +745,7 @@ module Emacs(M : sig end) = struct
|
|||
(* Rewrite toplevel expressions. *)
|
||||
let phrase = rewrite phrase in
|
||||
try
|
||||
Env.reset_cache_toplevel ();
|
||||
ignore (Toploop.execute_phrase true Format.std_formatter phrase);
|
||||
true
|
||||
with exn ->
|
||||
|
|
Loading…
Reference in New Issue