diff options
| author | herbelin | 2002-09-03 16:30:02 +0000 |
|---|---|---|
| committer | herbelin | 2002-09-03 16:30:02 +0000 |
| commit | 420143a1aeaaf152a4e10867fe74fb2079367ea5 (patch) | |
| tree | c1267c0e3601e64f1640cb51c3ade5b8986a1ec9 /pretyping | |
| parent | a5aa6380db920430299b858eb2e07b086f3d980c (diff) | |
pretyping/pretyping.ml
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@2986 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'pretyping')
| -rw-r--r-- | pretyping/cases.ml | 22 | ||||
| -rw-r--r-- | pretyping/pretype_errors.ml | 4 | ||||
| -rw-r--r-- | pretyping/pretype_errors.mli | 3 | ||||
| -rw-r--r-- | pretyping/rawterm.ml | 6 | ||||
| -rw-r--r-- | pretyping/rawterm.mli | 1 |
5 files changed, 24 insertions, 12 deletions
diff --git a/pretyping/cases.ml b/pretyping/cases.ml index f7c739fe6b..c552be7d6e 100644 --- a/pretyping/cases.ml +++ b/pretyping/cases.ml @@ -393,15 +393,18 @@ let rec find_row_ind = function exception NotCoercible -let inh_coerce_to_ind isevars env ty tyi = +let inh_coerce_to_ind isevars env tmloc ty tyi = let (mib,mip) = Inductive.lookup_mind_specif env tyi in let (ntys,_) = splay_prod env (evars_of isevars) mip.mind_nf_arity in - let (_,evarl) = + let hole_source = match tmloc with + | Some loc -> fun i -> (loc, TomatchTypeParameter (tyi,i)) + | None -> fun _ -> (dummy_loc, InternalHole) in + let (_,evarl,_) = List.fold_right - (fun (na,ty) (env,evl) -> + (fun (na,ty) (env,evl,n) -> (push_rel (na,None,ty) env, - (new_isevar isevars env (dummy_loc, InternalHole) ty)::evl)) - ntys (env,[]) in + (new_isevar isevars env (hole_source n) ty)::evl,n+1)) + ntys (env,[],1) in let expected_typ = applist (mkInd tyi,evarl) in (* devrait être indifférent d'exiger leq ou pas puisque pour un inductif cela doit être égal *) @@ -414,11 +417,11 @@ let inh_coerce_to_ind isevars env ty tyi = * use the function above. *) -let unify_tomatch_with_patterns isevars env typ = function +let unify_tomatch_with_patterns isevars env tmloc typ = function | Some (cloc,(cstr,_ as c)) -> (let tyi = inductive_of_constructor c in try - let indtyp = inh_coerce_to_ind isevars env typ tyi in + let indtyp = inh_coerce_to_ind isevars env tmloc typ tyi in IsInd (typ,find_rectype env (evars_of isevars) typ) with NotCoercible -> (* 2 cases : Not the right inductive or not an inductive at all *) @@ -435,7 +438,8 @@ let unify_tomatch_with_patterns isevars env typ = function let coerce_row typing_fun isevars env cstropt tomatch = let j = typing_fun empty_tycon env tomatch in let typ = body_of_type j.uj_type in - let t = unify_tomatch_with_patterns isevars env typ cstropt in + let loc = loc_of_rawconstr tomatch in + let t = unify_tomatch_with_patterns isevars env (Some loc) typ cstropt in (j.uj_val,t) let coerce_to_indtype typing_fun isevars env matx tomatchl = @@ -452,7 +456,7 @@ let coerce_to_indtype typing_fun isevars env matx tomatchl = let to_mutind env isevars tm c t = match c with | Some body -> NotInd (c,t) - | None -> unify_tomatch_with_patterns isevars env t (find_row_ind tm) + | None -> unify_tomatch_with_patterns isevars env None t (find_row_ind tm) let type_of_tomatch = function | IsInd (t,_) -> t diff --git a/pretyping/pretype_errors.ml b/pretyping/pretype_errors.ml index cc8b0ed8b3..4a60fce3d6 100644 --- a/pretyping/pretype_errors.ml +++ b/pretyping/pretype_errors.ml @@ -24,6 +24,7 @@ type pretype_error = (* Unification *) | OccurCheck of int * constr | NotClean of int * constr + | UnsolvableImplicit of hole_kind (* Pretyping *) | VarNotFound of identifier | UnexpectedType of constr * constr @@ -135,6 +136,9 @@ let error_not_clean env sigma ev c = let c = nf_evar sigma c in raise (PretypeError (env_ise sigma env, NotClean (ev,c))) +let error_unsolvable_implicit loc env sigma e = + raise (PretypeError (env_ise sigma env, UnsolvableImplicit e)) + (*s Ml Case errors *) let error_cant_find_case_type_loc loc env sigma expr = diff --git a/pretyping/pretype_errors.mli b/pretyping/pretype_errors.mli index c3921f2452..cb26d3078d 100644 --- a/pretyping/pretype_errors.mli +++ b/pretyping/pretype_errors.mli @@ -26,6 +26,7 @@ type pretype_error = (* Unification *) | OccurCheck of int * constr | NotClean of int * constr + | UnsolvableImplicit of hole_kind (* Pretyping *) | VarNotFound of identifier | UnexpectedType of constr * constr @@ -77,6 +78,8 @@ val error_occur_check : env -> Evd.evar_map -> int -> constr -> 'b val error_not_clean : env -> Evd.evar_map -> int -> constr -> 'b +val error_unsolvable_implicit : loc -> env -> Evd.evar_map -> hole_kind -> 'b + (*s Ml Case errors *) val error_cant_find_case_type_loc : diff --git a/pretyping/rawterm.ml b/pretyping/rawterm.ml index 0f376ae5e7..250fc70dcc 100644 --- a/pretyping/rawterm.ml +++ b/pretyping/rawterm.ml @@ -50,6 +50,7 @@ type hole_kind = | QuestionMark | CasesType | InternalHole + | TomatchTypeParameter of inductive * int type 'ctxt reference = | RConst of constant * 'ctxt @@ -163,9 +164,8 @@ let rec subst_raw subst raw = let ref' = subst_global subst ref in if ref' == ref then raw else RHole (loc,ImplicitArg (ref',i)) - | RHole (loc, - (AbstractionType _ | QuestionMark | CasesType | InternalHole)) -> - raw + | RHole (loc, (AbstractionType _ | QuestionMark | CasesType | + InternalHole | TomatchTypeParameter _)) -> raw | RCast (loc,r1,r2) -> let r1' = subst_raw subst r1 and r2' = subst_raw subst r2 in diff --git a/pretyping/rawterm.mli b/pretyping/rawterm.mli index e8b0726c9a..5f155aa2d9 100644 --- a/pretyping/rawterm.mli +++ b/pretyping/rawterm.mli @@ -49,6 +49,7 @@ type hole_kind = | QuestionMark | CasesType | InternalHole + | TomatchTypeParameter of inductive * int type 'ctxt reference = | RConst of constant * 'ctxt |
