-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[coq] Protect all base API calls, stop checking on anomaly
Work on tricky issues made me realize that we don't handle anomalies and Coq errors still in the best way, thus #91 is not really solved. There are 2 issues this PR solves: - goal printing can raise an anomalies and errors, due to setting state and printing, - it is safer to stop checking and set the document to failed when an anomaly happens (tho we could make this configurable). Thus, we go full principled in terms of API and make `Protect` mandatory on the exported APIs from `coq` library. We also introduce a `Failed` state that prevents further checking of that document without having finished it. Really fixes #91, and a step towards #153 TODO: protect calls to admit, but we leave this for a further PR as it is quite tricky due to error recovery needing rework to fully account for `Protect.R` results.
- Loading branch information
Showing
16 changed files
with
156 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
let parse ~st ps = | ||
let mode = State.mode ~st in | ||
let st = State.parsing ~st in | ||
(* Coq is missing this, so we add it here. Note that this MUST run inside | ||
coq_protect *) | ||
Control.check_for_interrupt (); | ||
Vernacstate.Parser.parse st Pvernac.(main_entry mode) ps | ||
|> Option.map Ast.of_coq | ||
|
||
let parse ~st ps = Protect.eval ~f:(parse ~st) ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
val parse : st:State.t -> Pcoq.Parsable.t -> Ast.t option Protect.R.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let pr_ltype_env ~goal_concl_style env sigma x = | ||
Printer.pr_ltype_env ~goal_concl_style env sigma x | ||
|
||
let pr_ltype_env ~goal_concl_style env sigma x = | ||
let f = pr_ltype_env ~goal_concl_style env sigma in | ||
match Protect.eval ~f x with | ||
| Protect.R.Completed (Ok pr) -> pr | ||
| _ -> Pp.str "printer failed!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
val pr_ltype_env : | ||
goal_concl_style:bool -> Environ.env -> Evd.evar_map -> Constr.t -> Pp.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.