-let typecheck_obj (uri,_height,metasenv,subst,kind) =
- (* height is not checked since it is only used to implement an optimization *)
+let height_of_obj_kind uri ~subst =
+ function
+ NCic.Inductive _
+ | NCic.Constant (_,_,None,_,_)
+ | NCic.Fixpoint (false,_,_) -> 0
+ | NCic.Fixpoint (true,ifl,_) ->
+ let iflno = List.length ifl in
+ height_of_term
+ (List.fold_left
+ (fun l (_,_,_,ty,bo) ->
+ let bo = debruijn uri iflno [] ~subst bo in
+ ty::bo::l
+ ) [] ifl)
+ | NCic.Constant (_,_,Some bo,ty,_) -> height_of_term [bo;ty]
+;;
+
+let typecheck_obj (uri,height,metasenv,subst,kind) =
+(*height must be checked since it is not only an optimization during reduction*)
+ let iheight = height_of_obj_kind uri ~subst kind in
+ if height <> iheight then
+ raise (TypeCheckerFailure (lazy (Printf.sprintf
+ "the declared object height (%d) is not the inferred one (%d)"
+ height iheight)));