From 928d186f5dcc649793ea9f3dd8f880d93786dfe7 Mon Sep 17 00:00:00 2001 From: herbelin Date: Sun, 13 Jun 2010 11:09:51 +0000 Subject: Fixed bug #2314 (inversion using not checking the correctness of its arguments enough) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13126 85f007b7-540e-0410-9357-904b9bb8a0f7 --- proofs/clenv.ml | 6 +++--- proofs/clenv.mli | 2 ++ tactics/leminv.ml | 5 ++++- test-suite/success/Inversion.v | 7 +++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/proofs/clenv.ml b/proofs/clenv.ml index dade69865c..8b4b41219b 100644 --- a/proofs/clenv.ml +++ b/proofs/clenv.ml @@ -440,11 +440,11 @@ let clenv_match_args bl clenv = clenv_assign_binding clenv k c) clenv bl +exception NoSuchBinding + let clenv_constrain_last_binding c clenv = let all_mvs = collect_metas clenv.templval.rebus in - let k = - try list_last all_mvs - with Failure _ -> anomaly "clenv_constrain_with_bindings" in + let k = try list_last all_mvs with Failure _ -> raise NoSuchBinding in clenv_assign_binding clenv k c let clenv_constrain_dep_args hyps_only bl clenv = diff --git a/proofs/clenv.mli b/proofs/clenv.mli index 209024c9c4..9a93adc440 100644 --- a/proofs/clenv.mli +++ b/proofs/clenv.mli @@ -85,6 +85,8 @@ type arg_bindings = constr explicit_bindings val clenv_independent : clausenv -> metavariable list val clenv_missing : clausenv -> metavariable list +(** for the purpose of inversion tactics *) +exception NoSuchBinding val clenv_constrain_last_binding : constr -> clausenv -> clausenv (** defines metas corresponding to the name of the bindings *) diff --git a/tactics/leminv.ml b/tactics/leminv.ml index abb114d917..6795b4817a 100644 --- a/tactics/leminv.ml +++ b/tactics/leminv.ml @@ -288,7 +288,10 @@ let lemInv id c gls = let clause = clenv_constrain_last_binding (mkVar id) clause in Clenvtac.res_pf clause ~allow_K:true gls with - | UserError (a,b) -> + | NoSuchBinding -> + errorlabstrm "" + (hov 0 (pr_constr c ++ spc () ++ str "does not refer to an inversion lemma.")) + | UserError (a,b) -> errorlabstrm "LemInv" (str "Cannot refine current goal with the lemma " ++ pr_lconstr_env (Global.env()) c) diff --git a/test-suite/success/Inversion.v b/test-suite/success/Inversion.v index 5091b44c1c..043d949c91 100644 --- a/test-suite/success/Inversion.v +++ b/test-suite/success/Inversion.v @@ -129,3 +129,10 @@ Proof. an inconsistent state that disturbed "inversion" *) intros. inversion H. Abort. + +(* Bug #2314 (simplified): check that errors do not show as anomalies *) + +Goal True -> True. +intro. +Fail inversion H using False. +Fail inversion foo using True_ind. -- cgit v1.2.3