Skip to content

Commit

Permalink
Fix "tip not cached" anomaly when there are open proofs at file end
Browse files Browse the repository at this point in the history
Fix #16335
  • Loading branch information
SkySkimmer committed May 18, 2023
1 parent 90687b4 commit 2a81292
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions ide/coqide/idetop.ml
Expand Up @@ -305,8 +305,7 @@ let status force =
(usually Top in an interactive session, cf "coqtop -top"),
and display the other parts (opened sections and modules) *)
ignore (Stm.finish ~doc:(get_doc ()) : Vernacstate.t);
if force then
ignore (Stm.join ~doc:(get_doc ()) : Vernacstate.t);
if force then Stm.join ~doc:(get_doc ());
let path =
let l = Names.DirPath.repr (Lib.cwd ()) in
List.rev_map Names.Id.to_string l
Expand Down
5 changes: 2 additions & 3 deletions stm/stm.ml
Expand Up @@ -2429,7 +2429,7 @@ let finish ~doc =
let () = observe ~doc (VCS.get_branch_pos head) in
let tip = VCS.cur_tip () in
if not (State.is_cached ~cache:true tip) then
CErrors.anomaly Pp.(str "Stm.join: tip not cached");
CErrors.anomaly Pp.(str "Stm.finish: tip not cached");
VCS.print ();
State.get_cached tip

Expand Down Expand Up @@ -2473,8 +2473,7 @@ let join ~doc =
let tip = VCS.cur_tip () in
if not (State.is_cached ~cache:true tip) then
CErrors.anomaly Pp.(str "Stm.join: tip not cached");
VCS.print ();
State.get_cached tip
VCS.print ()

type tasks = Opaqueproof.opaque_handle option Slaves.tasks
let check_task name tasks i =
Expand Down
2 changes: 1 addition & 1 deletion stm/stm.mli
Expand Up @@ -136,7 +136,7 @@ val wait : doc:doc -> unit
val stop_worker : string -> unit

(* Joins the entire document. Implies finish, but also checks proofs *)
val join : doc:doc -> Vernacstate.t
val join : doc:doc -> unit

(* Saves on the disk a .vio corresponding to the current status:
- if the worker pool is empty, all tasks are saved
Expand Down
3 changes: 3 additions & 0 deletions test-suite/output/bug_16335.out
@@ -0,0 +1,3 @@
Error: There are pending proofs in file ./output/bug_16335.v: foo.

coqc exited with code 1
2 changes: 2 additions & 0 deletions test-suite/output/bug_16335.v
@@ -0,0 +1,2 @@
Lemma foo: True.
Proof.
5 changes: 3 additions & 2 deletions toplevel/ccompile.ml
Expand Up @@ -68,9 +68,10 @@ let compile opts stm_options injections copts ~echo ~f_in ~f_out =
let check = Stm.AsyncOpts.(stm_options.async_proofs_mode = APoff) in
let source = source copts ldir long_f_dot_in in
let state = Vernac.load_vernac ~echo ~check ~interactive:false ~state ~source long_f_dot_in in
let state = Stm.join ~doc:state.doc in
let fullstate = Stm.finish ~doc:state.doc in
ensure_no_pending_proofs ~filename:long_f_dot_in fullstate;
let () = Stm.join ~doc:state.doc in
let wall_clock2 = Unix.gettimeofday () in
ensure_no_pending_proofs ~filename:long_f_dot_in state;
(* In .vo production, dump a complete .vo file. *)
if mode = BuildVo
then Library.save_library_to ~output_native_objects Library.ProofsTodoNone ldir long_f_dot_out;
Expand Down

0 comments on commit 2a81292

Please sign in to comment.