let pp _ = ();;
-let fix_sorts swap metasenv subst context meta t =
+let fix_sorts swap exc t =
let rec aux () = function
| NCic.Sort (NCic.Type u) as orig ->
if swap then
match NCicEnvironment.sup u with
- | None -> prerr_endline "no sup for" ;
- raise (fail_exc metasenv subst context meta t)
+ | None -> prerr_endline "no sup for" ; raise exc
| Some u1 -> if u = u1 then orig else NCic.Sort (NCic.Type u1)
else
NCic.Sort (NCic.Type (
"typeof: " ^ NCicPp.ppterm ~metasenv ~subst ~context t ^ "\nctx:\n"^
ppcontext ~metasenv ~subst context ^ "\nmenv:\n"^
ppmetasenv ~subst metasenv));
+ let exc_to_be = fail_exc metasenv subst context (NCic.Meta (n,lc)) t in
let t, ty_t =
try t, NCicTypeChecker.typeof ~subst ~metasenv context t
with
| NCicTypeChecker.AssertFailure msg ->
(pp (lazy "fine typeof (fallimento)");
- let ft=fix_sorts swap metasenv subst context (NCic.Meta (n,lc)) t in
+ let ft = fix_sorts swap exc_to_be t in
if ft == t then
(prerr_endline ( ("ILLTYPED: " ^
NCicPp.ppterm ~metasenv ~subst ~context t
prerr_endline (Lazy.force msg);
pp msg; assert false
in
+ let ty_t = fix_sorts swap exc_to_be ty_t in
let lty = NCicSubstitution.subst_meta lc ty in
match ty_t with
| NCic.Implicit _ ->
(C.Meta (i,l)) lambda_Mj,
i
| NCic.Meta (i,_) -> (metasenv, subst), i
- | _ -> assert false
+ | _ -> prerr_endline ("XXX: " ^ NCicPp.ppterm ~metasenv ~subst ~context (NCicReduction.whd ~subst context t1)); assert false
in
let t1 = NCicReduction.whd ~subst context t1 in
let j, lj =