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

Fix "tip not cached" anomaly when there are open proofs at file end #17620

Merged
merged 2 commits into from May 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
26 changes: 12 additions & 14 deletions stm/stm.ml
Expand Up @@ -1189,17 +1189,16 @@ end = struct (* {{{ *)
match np with
| None -> None
| Some cp ->
let did = ref id in
let rv = ref np in
let done_ = ref false in
while not !done_ do
did := fold_until back_tactic 1 !did;
rv := get_proof ~doc !did;
done_ := match !rv with
| Some rv -> not (Evar.Set.equal (Proof.all_goals rv) (Proof.all_goals cp))
| None -> true
done;
!rv
let rec search did =
let did = fold_until back_tactic 1 did in
match get_proof ~doc did with
| None -> None
| Some rv ->
if Evar.Set.equal (Proof.all_goals rv) (Proof.all_goals cp)
then search did
else Some rv
in
search id
with Not_found | PG_compat.NoCurrentProof -> None

end (* }}} *)
Expand Down Expand Up @@ -2430,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 @@ -2474,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
SkySkimmer marked this conversation as resolved.
Show resolved Hide resolved
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