From c43f9128237ac16fa0d7741744e3944ca72e7475 Mon Sep 17 00:00:00 2001 From: herbelin Date: Thu, 28 Feb 2013 07:33:37 +0000 Subject: More informative error when a global reference is used in a context of local variables which is a different from the one of its definition. E.g.: Section A. Variable n:nat. Definition c:=n. Goal True. clear n. Check c. [I'm however unsure that "n" should not continue to be accessible via some global (qualified) name, even after the "clear n".] git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16256 85f007b7-540e-0410-9357-904b9bb8a0f7 --- pretyping/nativenorm.ml | 5 +++-- pretyping/vnorm.ml | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'pretyping') diff --git a/pretyping/nativenorm.ml b/pretyping/nativenorm.ml index 0ecbfdbb4c..6af9ff3233 100644 --- a/pretyping/nativenorm.ml +++ b/pretyping/nativenorm.ml @@ -167,8 +167,9 @@ let rec nf_val env v typ = let lvl = nb_rel env in let name,dom,codom = try decompose_prod env typ - with _ -> (* TODO: is this the right exception to raise? *) - raise (Type_errors.TypeError(env,Type_errors.ReferenceVariables typ)) + with Invalid_argument _ -> + Errors.anomaly + (Pp.strbrk "Returned a functional value in a type not recognized as a product type.") in let env = push_rel (name,None,dom) env in let body = nf_val env (f (mk_rel_accu lvl)) codom in diff --git a/pretyping/vnorm.ml b/pretyping/vnorm.ml index 82eccab96d..b18719cc27 100644 --- a/pretyping/vnorm.ml +++ b/pretyping/vnorm.ml @@ -249,8 +249,10 @@ and nf_fun env f typ = let vb = body_of_vfun k f in let name,dom,codom = try decompose_prod env typ - with _ -> - raise (Type_errors.TypeError(env,Type_errors.ReferenceVariables typ)) + with Invalid_argument _ -> + (* 27/2/13: Turned this into an anomaly *) + Errors.anomaly + (Pp.strbrk "Returned a functional value in a type not recognized as a product type.") in let body = nf_val (push_rel (name,None,dom) env) vb codom in mkLambda(name,dom,body) -- cgit v1.2.3