]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_unification/freshNamesGenerator.ml
version 0.7.1
[helm.git] / helm / ocaml / cic_unification / freshNamesGenerator.ml
index fbb90552aa9e4293792743a3329e248c9b24ae90..97353c3e73cee0c1ba5e710fa368f5c399127d1d 100644 (file)
@@ -23,6 +23,8 @@
  * http://cs.unibo.it/helm/.
  *)
 
+let debug_print = fun _ -> ()
+
 (* mk_fresh_name context name typ                      *)
 (* returns an identifier which is fresh in the context *)
 (* and that resembles [name] as much as possible.      *)
@@ -49,17 +51,19 @@ let mk_fresh_name ~subst metasenv context name ~typ =
        Str.global_replace (Str.regexp "[0-9]*$") "" name
   in
    let already_used name =
-    List.exists (function Some (C.Name n,_) -> n=name | _ -> false) context
+    List.exists (function Some (n,_) -> n=name | _ -> false) context
    in
-    if not (already_used basename) then
+    if name <> C.Anonymous && not (already_used name) then
+     name
+    else if not (already_used (C.Name basename)) then
      C.Name basename
     else
      let rec try_next n =
-      let name' = basename ^ string_of_int n in
+      let name' = C.Name (basename ^ string_of_int n) in
        if already_used name' then
         try_next (n+1)
        else
-        C.Name name'
+        name'
      in
       try_next 1
 ;;
@@ -111,7 +115,7 @@ let clean_dummy_dependent_types t =
             C.Anonymous ->
              if List.mem k rels2 then
 (
-              prerr_endline "If this happens often, we can do something about it (i.e. we can generate a new fresh name; problem: we need the metasenv and context ;-(. Alternative solution: mk_implicit does not generate entries for the elements in the context that have no name" ;
+              debug_print "If this happens often, we can do something about it (i.e. we can generate a new fresh name; problem: we need the metasenv and context ;-(. Alternative solution: mk_implicit does not generate entries for the elements in the context that have no name" ;
               C.Anonymous
 )
              else