Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring the old error handler in Errors.catch_errors_aux #2965

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions ocaml/fstar-lib/generated/FStar_Errors.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion ocaml/fstar-lib/generated/FStar_Tactics_Basic.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions src/basic/FStar.Errors.fst
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,24 @@ let catch_errors_aux (f : unit -> 'a) : list issue & list issue & option 'a =
let newh = mk_default_handler false in
let old = !current_handler in
current_handler := newh;
let finally_restore () =
let all_issues = newh.eh_report() in //de-duplicated already
current_handler := old;
let errs, rest = List.partition (fun i -> i.issue_level = EError) all_issues in
errs, rest
in
let r = try Some (f ())
with | ex -> err_exn ex; None
with
| ex when handleable ex ->
err_exn ex;
None
| ex ->
let _ = finally_restore() in
raise ex
in
let all_issues = newh.eh_report() in //de-duplicated already
current_handler := old;
let errs, rest = List.partition (fun i -> i.issue_level = EError) all_issues in
let errs, rest = finally_restore() in
errs, rest, r

let no_ctx (f : unit -> 'a) : 'a =
let save = error_context.get () in
error_context.clear ();
Expand Down
13 changes: 12 additions & 1 deletion src/tactics/FStar.Tactics.Basic.fst
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,18 @@ let dbg_refl (g:env) (msg:unit -> string) =
let issues = list Errors.issue
let refl_typing_builtin_wrapper (f:unit -> 'a) : tac (option 'a & issues) =
let tx = UF.new_transaction () in
let errs, r = Errors.catch_errors_and_ignore_rest f in
let errs, r =
try Errors.catch_errors_and_ignore_rest f
with exn -> //catch everything
let issue = FStar.Errors.({
issue_msg = BU.print_exn exn;
issue_level = EError;
issue_range = None;
issue_number = (Some 17);
issue_ctx = get_ctx ()
}) in
[issue], None
in
UF.rollback tx;
if List.length errs > 0
then ret (None, errs)
Expand Down