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
|
} in
|
||||||
let check_phrase = Parsetree.Ptop_def [top_def] in
|
let check_phrase = Parsetree.Ptop_def [top_def] in
|
||||||
try
|
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. *)
|
(* The phrase is safe. *)
|
||||||
Toploop.toplevel_env := env;
|
Toploop.toplevel_env := env;
|
||||||
Btype.backtrack snap;
|
Btype.backtrack snap;
|
||||||
None
|
None
|
||||||
with exn ->
|
with exn ->
|
||||||
(* The phrase contains errors. *)
|
(* The phrase contains errors. *)
|
||||||
|
let loc, msg = get_ocaml_error_message exn in
|
||||||
Toploop.toplevel_env := env;
|
Toploop.toplevel_env := env;
|
||||||
Btype.backtrack snap;
|
Btype.backtrack snap;
|
||||||
let loc, msg = get_ocaml_error_message exn in
|
|
||||||
Some ([loc], msg)
|
Some ([loc], msg)
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
|
|
|
@ -538,6 +538,9 @@ let rec loop term =
|
||||||
let pp = Format.formatter_of_buffer buffer in
|
let pp = Format.formatter_of_buffer buffer in
|
||||||
Format.pp_set_margin pp (LTerm.size term).cols;
|
Format.pp_set_margin pp (LTerm.size term).cols;
|
||||||
(try
|
(try
|
||||||
|
#if ocaml_version > (4, 00, 1)
|
||||||
|
Env.reset_cache_toplevel ();
|
||||||
|
#endif
|
||||||
ignore (Toploop.execute_phrase true pp phrase);
|
ignore (Toploop.execute_phrase true pp phrase);
|
||||||
(* Flush everything. *)
|
(* Flush everything. *)
|
||||||
Format.pp_print_flush Format.std_formatter ();
|
Format.pp_print_flush Format.std_formatter ();
|
||||||
|
@ -742,6 +745,7 @@ module Emacs(M : sig end) = struct
|
||||||
(* Rewrite toplevel expressions. *)
|
(* Rewrite toplevel expressions. *)
|
||||||
let phrase = rewrite phrase in
|
let phrase = rewrite phrase in
|
||||||
try
|
try
|
||||||
|
Env.reset_cache_toplevel ();
|
||||||
ignore (Toploop.execute_phrase true Format.std_formatter phrase);
|
ignore (Toploop.execute_phrase true Format.std_formatter phrase);
|
||||||
true
|
true
|
||||||
with exn ->
|
with exn ->
|
||||||
|
|
Loading…
Reference in New Issue