module C = NCic
module Ref = NReference
+let debug = ref false;;
let indent = ref "";;
-let inside c = indent := !indent ^ String.make 1 c;;
-let outside () = indent := String.sub !indent 0 (String.length !indent -1);;
-
-
-let pp s =
+let pp s =
+ if !debug then
prerr_endline (Printf.sprintf "%-20s" !indent ^ " " ^ Lazy.force s)
-;;
+ else
+ ()
+;;
+let inside c =
+ indent := !indent ^ String.make 1 c;
+ if !debug then prerr_endline ("{{{" ^ !indent ^ " ")
+;;
+let outside ok =
+ if !debug then prerr_endline "}}}";
+ if not ok then pp (lazy "exception raised!");
+ try
+ indent := String.sub !indent 0 (String.length !indent -1)
+ with
+ Invalid_argument _ -> indent := "??"; ()
+;;
-let pp _ = ();;
let wrap_exc msg = function
| NCicUnification.Uncertain _ -> Uncertain msg
with exc -> raise (wrap_exc (lazy (localise orig,
"Sort elimination not allowed ")) exc))
| _ -> assert false
- (*D*)in outside(); rc with exc -> outside (); raise exc
+ (*D*)in outside true; rc with exc -> outside false; raise exc
in
aux
;;
let metasenv, subst =
(*D*)inside 'U'; try let rc =
NCicUnification.unify rdb metasenv subst context infty expty
- (*D*)in outside(); rc with exc -> outside (); raise exc
+ (*D*)in outside true; rc with exc -> outside false; raise exc
in
metasenv, subst, t, expty
with
try_coercions rdb ~localise
metasenv subst context t orig infty expty true exc)
| None -> metasenv, subst, t, infty
- (*D*)in outside(); rc with exc -> outside (); raise exc
+ (*D*)in outside true; rc with exc -> outside false; raise exc
in
let rec typeof_aux metasenv subst context expty =
fun t as orig ->
| Some x ->
let m, s, x =
NCicUnification.delift_type_wrt_terms
- rdb metasenv subst context x [t]
+ rdb metasenv subst context1 (NCicSubstitution.lift 1 x)
+ [NCicSubstitution.lift 1 t]
in
m, s, Some x
in
pp (lazy (NCicPp.ppterm ~metasenv ~subst ~context t ^ " ::inf:: "^
NCicPp.ppterm ~metasenv ~subst ~context infty ));
force_ty true true metasenv subst context orig t infty expty
- (*D*)in outside(); rc with exc -> outside (); raise exc
+ (*D*)in outside true; rc with exc -> outside false; raise exc
in
typeof_aux metasenv subst context expty term
let rec first exc = function
| [] ->
raise (wrap_exc (lazy (localise orig_t, Printf.sprintf
- "The term %s has type %s but is here used with type %s"
+ "The term\n%s\nhas type\n%s\nbut is here used with type\n%s"
(NCicPp.ppterm ~metasenv ~subst ~context t)
(NCicPp.ppterm ~metasenv ~subst ~context infty)
(NCicPp.ppterm ~metasenv ~subst ~context expty))) exc)
List.partition (fun (i,_) -> i <= highest_meta) metasenv
in
(List.rev metasenv_new) @ metasenv_old, subst, newhead, newheadty
- (*D*)in outside(); rc with exc -> outside (); raise exc
+ (*D*)in outside true; rc with exc -> outside false; raise exc
;;
let rec first f l1 l2 =