aboutsummaryrefslogtreecommitdiffhomepage
path: root/checker
diff options
context:
space:
mode:
authorGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2014-04-27 15:09:04 +0200
committerGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2014-04-28 09:40:46 +0200
commit5eb53b5bc8d765ed75e965f43f1084e18efc8790 (patch)
tree31c87e5f8c9f6cff5f2277912240a2a2f565bc90 /checker
parent6541e32be7018104c47ccad75ff41ffc750ff944 (diff)
Adding a field ci_cstr_nargs to case_info and mind_consnrealargs to
one_inductive_body so that when eta-expanding at "match" printing time we know if a let is part of the expected signature or part of the body. This is an easy fix for bugs like #3293. Another fix could be to enforce, as an invariant, or better syntactically, that "match"/"Case"'s have the body of their branches expanded.
Diffstat (limited to 'checker')
-rw-r--r--checker/cic.mli7
-rw-r--r--checker/declarations.ml1
-rw-r--r--checker/inductive.ml3
3 files changed, 9 insertions, 2 deletions
diff --git a/checker/cic.mli b/checker/cic.mli
index bfea85327..380093c57 100644
--- a/checker/cic.mli
+++ b/checker/cic.mli
@@ -60,7 +60,8 @@ type case_printing =
type case_info =
{ ci_ind : inductive;
ci_npar : int;
- ci_cstr_ndecls : int array; (** number of real args of each constructor *)
+ ci_cstr_ndecls : int array; (* number of pattern vars of each constructor (with let's)*)
+ ci_cstr_nargs : int array; (* number of pattern vars of each constructor (w/o let's) *)
ci_pp_info : case_printing (** not interpreted by the kernel *)
}
@@ -241,6 +242,10 @@ type one_inductive_body = {
(** Length of the signature of the constructors (with let, w/o params)
(not used in the kernel) *)
+ mind_consnrealargs : int array;
+ (** Length of the signature of the constructors (w/o let, w/o params)
+ (not used in the kernel) *)
+
mind_recargs : wf_paths; (** Signature of recursive arguments in the constructors *)
(** {8 Datas for bytecode compilation } *)
diff --git a/checker/declarations.ml b/checker/declarations.ml
index 79ba6de22..baf2e57db 100644
--- a/checker/declarations.ml
+++ b/checker/declarations.ml
@@ -510,6 +510,7 @@ let subst_arity sub = function
let subst_mind_packet sub mbp =
{ mind_consnames = mbp.mind_consnames;
mind_consnrealdecls = mbp.mind_consnrealdecls;
+ mind_consnrealargs = mbp.mind_consnrealargs;
mind_typename = mbp.mind_typename;
mind_nf_lc = Array.smartmap (subst_mps sub) mbp.mind_nf_lc;
mind_arity_ctxt = subst_rel_context sub mbp.mind_arity_ctxt;
diff --git a/checker/inductive.ml b/checker/inductive.ml
index 40a9bc316..e6a24f705 100644
--- a/checker/inductive.ml
+++ b/checker/inductive.ml
@@ -352,7 +352,8 @@ let check_case_info env indsp ci =
if
not (eq_ind indsp ci.ci_ind) ||
(mib.mind_nparams <> ci.ci_npar) ||
- (mip.mind_consnrealdecls <> ci.ci_cstr_ndecls)
+ (mip.mind_consnrealdecls <> ci.ci_cstr_ndecls) ||
+ (mip.mind_consnrealargs <> ci.ci_cstr_nargs)
then raise (TypeError(env,WrongCaseInfo(indsp,ci)))
(************************************************************************)