module NRef = NReference
-let wrap f x =
+let wrap fname f x =
try f x
with
| MultiPassDisambiguator.DisambiguationError _
| NCicRefiner.RefineFailure _
| NCicUnification.UnificationFailure _
| NCicTypeChecker.TypeCheckerFailure _
- | NCicMetaSubst.MetaSubstFailure _ as exn -> fail ~exn (lazy "")
+ | NCicMetaSubst.MetaSubstFailure _ as exn -> fail ~exn (lazy fname)
;;
class pstatus =
let status = status#set_obj (u, d, metasenv, subst, o) in
status, (destination, t)
;;
-let relocate a b c = wrap (relocate a b) c;;
+let relocate a b c = wrap "relocate" (relocate a b) c;;
let term_of_cic_term s t c =
let s, (_,t) = relocate s c t in
let new_pstatus = uri,height,metasenv,subst,obj in
status#set_obj new_pstatus, (context, t)
;;
-let disambiguate a b c d = wrap (disambiguate a b c) d;;
+let disambiguate a b c d = wrap "disambiguate" (disambiguate a b c) d;;
let typeof status ctx t =
let status, (_,t) = relocate status ctx t in
let ty = NCicTypeChecker.typeof ~subst ~metasenv ctx t in
status, (ctx, ty)
;;
-let typeof a b c = wrap (typeof a b) c;;
+let typeof a b c = wrap "typeof" (typeof a b) c;;
let whd status ?delta ctx t =
let status, (_,t) = relocate status ctx t in
let metasenv, subst = NCicUnification.unify status metasenv subst ctx a b in
status#set_obj (n,h,metasenv,subst,o)
;;
-let unify a b c d = wrap (unify a b c) d;;
+let unify a b c d = wrap "unify" (unify a b c) d;;
let fix_sorts (ctx,t) =
let f () =
let t = NCicUnification.fix_sorts t in
ctx,t
in
- wrap f ()
+ wrap "fix_sorts" f ()
;;
let refine status ctx term expty =
in
status#set_obj (name,height,metasenv,subst,obj), (ctx,t), (ctx,ty)
;;
-let refine a b c d = wrap (refine a b c) d;;
+let refine a b c d = wrap "refine" (refine a b c) d;;
let get_goalty status g =
let _,_,metasenv,_,_ = status#obj in
- let _, a, b = List.assoc g metasenv in
- a, b
+ try
+ let _, ctx, ty = NCicUtils.lookup_meta g metasenv in
+ ctx, ty
+ with NCicUtils.Meta_not_found _ as exn -> fail ~exn (lazy "get_goalty")
;;
let instantiate status i t =