@@ -57,6 +57,9 @@ module State = struct
5757 sid : Stateid .t ;
5858 proof : Proof .t option ;
5959 time : time_output option ;
60+ failed_proofs : Names.Id .t list ;
61+ in_recovery : bool ;
62+ recovery_mode : bool ;
6063 }
6164
6265end
@@ -72,26 +75,57 @@ let emit_time state com tstart tend =
7275
7376let interp_vernac ~check ~state ({CAst. loc;_} as com ) =
7477 let open State in
78+
79+ let current_proof_name =
80+ match state.proof with
81+ Some prf -> Some ((Proof. data prf).name)
82+ | None -> None in
83+
84+ let admitted_com =
85+ CAst. make { control = [] ; attrs = [] ; expr =
86+ (VernacSynPure (VernacEndProof Admitted ))}in
7587 try
76- let doc, nsid, ntip = Stm. add ~doc: state.doc ~ontop: state.sid (not ! Flags. quiet) com in
88+
89+ let new_recovery_status, the_com =
90+ if state.in_recovery then
91+ (match Vernac_classifier. classify_vernac com with
92+ Vernacextend. VtQed _ -> false , Some admitted_com
93+ | _ -> true , None )
94+ else false , Some com in
95+
96+ let doc, nsid, ntip =
97+ match the_com with
98+ | Some com ->
99+ Stm. add ~doc: state.doc ~ontop: state.sid (not ! Flags. quiet) com
100+ | None -> state.doc, state.sid, Stm. NewAddTip in
77101
78102 (* Main STM interaction *)
79103 if ntip <> Stm. NewAddTip then
80104 anomaly (str " vernac.ml: We got an unfocus operation on the toplevel!" );
81-
105+
106+
82107 (* Force the command *)
83- let () = if check then Stm. observe ~doc nsid in
108+ let () = if check && not state.in_recovery then Stm. observe ~doc nsid in
84109 let new_proof = Vernacstate.Declare. give_me_the_proof_opt () [@ ocaml.warning " -3" ] in
85- { state with doc; sid = nsid; proof = new_proof; }
86- with reraise ->
87- let (reraise, info) = Exninfo. capture reraise in
110+ { state with doc; sid = nsid; proof = new_proof;
111+ in_recovery = new_recovery_status}
112+ with potentially_catched ->
113+ let (reraise, info) = Exninfo. capture potentially_catched in
88114 let info =
89115 (* Set the loc to the whole command if no loc *)
90116 match Loc. get_loc info, loc with
91117 | None , Some loc -> Loc. add_loc info loc
92- | Some _ , _ | _ , None -> info
93- in
94- Exninfo. iraise (reraise, info)
118+ | Some _ , _ | _ , None -> info in
119+ if state.recovery_mode then
120+ match current_proof_name with
121+ Some proof_name ->
122+ if CErrors. noncritical potentially_catched then
123+ {state with in_recovery = true ;
124+ failed_proofs = proof_name :: state .failed_proofs}
125+ else
126+ Exninfo. iraise (reraise, info)
127+ | None -> Exninfo. iraise (reraise, info)
128+ else Exninfo. iraise (reraise, info)
95129
96130(* Load a vernac file. CErrors are annotated with file and location *)
97131let load_vernac_core ~echo ~check ~state ?source file =
@@ -225,6 +259,12 @@ let beautify_pass ~doc ~comments ~ids ~filename =
225259 pass. *)
226260let load_vernac ~echo ~check ~state ?source filename =
227261 let ostate, ids, comments = load_vernac_core ~echo ~check ~state ?source filename in
262+ if 1 < = List. length (ostate.failed_proofs) then
263+ user_err (Pp. str " proofs failed in this file "
264+ ++ (ostate.failed_proofs
265+ |> List. rev
266+ |> prlist_with_sep pr_comma Names.Id. print)
267+ ++ str " ." );
228268 (* Pass for beautify *)
229269 if ! Flags. beautify then beautify_pass ~doc: ostate.State. doc ~comments ~ids: (List. rev ids) ~filename ;
230270 (* End pass *)
0 commit comments