diff options
author | Jason Gross <jgross@mit.edu> | 2019-03-14 16:14:45 -0400 |
---|---|---|
committer | Jason Gross <jasongross9@gmail.com> | 2019-03-31 09:31:15 -0400 |
commit | a8b4394093e61b050406ca952a6d017ad1c737e4 (patch) | |
tree | e75e2c0d33fd5a7fc4c46c3460b04530c30aa260 /src/Rewriter.v | |
parent | b18cfd89e1e8760185d9f50dd777c1c8096cf807 (diff) |
Add constr_fail and constr_fail_with
Rather than taking the convention that failures during constr
construction emit a type error from `I : I` with the actual error
message `idtac`d above them (because Coq has no way to emit multiple
things on stderr), we instead factor everything through a new
`constr_fail` or `constr_fail_with msg_tac`, which emit more helpful
messages instructing the user to look in `*coq*` or to use `Fail`/`try`
to see the more informative error message. When we can make our own
version that does both `idtac` and `fail` (c.f.
https://github.com/coq/coq/issues/3913), then we can do something a bit
more sane, hopefully.
Diffstat (limited to 'src/Rewriter.v')
-rw-r--r-- | src/Rewriter.v | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Rewriter.v b/src/Rewriter.v index 01d7614e3..2ccfb342d 100644 --- a/src/Rewriter.v +++ b/src/Rewriter.v @@ -10,6 +10,7 @@ Require Import Crypto.Util.ZRange. Require Import Crypto.Util.ZRange.Operations. Require Import Crypto.Util.ZUtil.Definitions. Require Import Crypto.Util.ZUtil.Notations. +Require Import Crypto.Util.Tactics.ConstrFail. Require Crypto.Util.PrimitiveProd. Require Crypto.Util.PrimitiveHList. Require Import Crypto.Language. @@ -1450,8 +1451,8 @@ Module Compilers. Ltac strip_functional_dependency term := lazymatch term with | fun _ => ?P => P - | _ => let __ := match goal with _ => idtac "Cannot eliminate functional dependencies of" term; fail 1 "Cannot eliminate functional dependencies of" term end in - constr:(I : I) + | _ => constr_fail_with ltac:(fun _ => idtac "Cannot eliminate functional dependencies of" term; + fail 1 "Cannot eliminate functional dependencies of" term) end. Ltac reify_under_forall_types' ty_ctx cur_i lem cont := @@ -1505,8 +1506,7 @@ Module Compilers. end) | @eq ?T ?A ?B => constr:((@eq T A B, side_conditions)) - | ?T => let __ := match goal with _ => fail 1 "Invalid type of equation:" T end in - constr:(I : I) + | ?T => constr_fail_with ltac:(fun _ => fail 1 "Invalid type of equation:" T) end. Ltac equation_to_parts lem := equation_to_parts' lem (@nil bool). @@ -1781,10 +1781,7 @@ Module Compilers. lazymatch rf0 with | (fun _ => ?f) => f | _ - => let __ := match goal with - | _ => fail 1 "Failure to eliminate functional dependencies of" rf0 - end in - constr:(I : I) + => constr_fail_with ltac:(fun _ => fail 1 "Failure to eliminate functional dependencies of" rf0) end | (@eq ?T ?A ?B, ?side_conditions) => let rA := expr.reify_in_context base.type ident ltac:(base.reify) reify_ident var_pos A value_ctx tt in @@ -2089,7 +2086,7 @@ Module Compilers. let next := match body with | context[@id ?t ?v] => lazymatch so_far with - | context[cons (existT _ _ v) _] => constr:(I : I) + | context[cons (existT _ _ v) _] => constr_fail | _ => constr:(@Some _ v) end | _ => constr:(@None unit) |