diff options
author | Enrico Tassi <Enrico.Tassi@inria.fr> | 2018-04-04 10:11:55 +0200 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2018-04-04 10:11:55 +0200 |
commit | deeb036d009bff0ad250832843b179d425f40b8c (patch) | |
tree | 83d9cd5590cd62c0d2edb175d54fbbec9cdbdbf2 /toplevel | |
parent | 630cdb53a6ba180f4d67cb1e848978239a0d09ea (diff) | |
parent | 0b48c57d705873d142cb4b19f959d1e7fab116c8 (diff) |
Merge PR #7144: [toplevel] Protect goal printing better wrt Break [helps with #7142]
Diffstat (limited to 'toplevel')
-rw-r--r-- | toplevel/coqloop.ml | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/toplevel/coqloop.ml b/toplevel/coqloop.ml index 371be20d2..d0989cfcc 100644 --- a/toplevel/coqloop.ml +++ b/toplevel/coqloop.ml @@ -325,6 +325,24 @@ let cproof p1 p2 = let drop_last_doc = ref None +(* We try to behave better when goal printing raises an exception + [usually Ctrl-C] + + This is mostly a hack as we should protect printing in a more + generic way, but that'll do for now *) +let top_goal_print oldp newp = + try + let proof_changed = not (Option.equal cproof oldp newp) in + let print_goals = not !Flags.quiet && + proof_changed && Proof_global.there_are_pending_proofs () in + if print_goals then Feedback.msg_notice (pr_open_cur_subgoals ()) + with + | exn -> + let (e, info) = CErrors.push exn in + let loc = Loc.get_loc info in + let msg = CErrors.iprint (e, info) in + TopErr.print_error_for_buffer ?loc Feedback.Error msg top_buffer + (* Careful to keep this loop tail-rec *) let rec vernac_loop ~state = let open CAst in @@ -353,10 +371,7 @@ let rec vernac_loop ~state = else (Feedback.msg_warning (str "There is no ML toplevel."); vernac_loop ~state) | {v=VernacControl c; loc} -> let nstate = Vernac.process_expr ~state (make ?loc c) in - let proof_changed = not (Option.equal cproof nstate.proof state.proof) in - let print_goals = not !Flags.quiet && - proof_changed && Proof_global.there_are_pending_proofs () in - if print_goals then Feedback.msg_notice (pr_open_cur_subgoals ()); + top_goal_print state.proof nstate.proof; vernac_loop ~state:nstate with | Stm.End_of_input -> |