get_thms etc.: improved reporting of source position;
authorwenzelm
Thu, 20 Mar 2008 17:38:54 +0100
changeset 26367 06635166d211
parent 26366 5c089f4219c2
child 26368 3e74b09ce466
get_thms etc.: improved reporting of source position;
src/Pure/pure_thy.ML
--- a/src/Pure/pure_thy.ML	Thu Mar 20 17:38:53 2008 +0100
+++ b/src/Pure/pure_thy.ML	Thu Mar 20 17:38:54 2008 +0100
@@ -168,9 +168,6 @@
 
 (** retrieve theorems **)
 
-fun the_thms _ (SOME thms) = thms
-  | the_thms name NONE = error ("Unknown theorem(s) " ^ quote name);
-
 local
 
 fun lookup_thms thy xname =
@@ -191,6 +188,7 @@
 fun get silent theory thmref =
   let
     val name = Facts.name_of_ref thmref;
+    val pos = Facts.pos_of_ref thmref;
     val new_res = lookup_fact theory name;
     val old_res = get_first (fn thy => lookup_thms thy name) (theory :: Theory.ancestors_of theory);
     val is_same =
@@ -201,9 +199,12 @@
     val _ =
       if is_same orelse silent then ()
       else legacy_feature ("Fact lookup differs from old-style thm database:\n" ^
-        show_result new_res ^ " vs " ^ show_result old_res ^
-        Position.str_of (Position.thread_data ()));
-  in Option.map #2 old_res |> the_thms name |> Facts.select thmref |> map (Thm.transfer theory) end;
+        show_result new_res ^ " vs " ^ show_result old_res ^ Position.str_of pos);
+  in
+    (case old_res of
+      NONE => error ("Unknown theorem(s) " ^ quote name ^ Position.str_of pos)
+    | SOME (_, ths) => Facts.select thmref (map (Thm.transfer theory) ths))
+  end;
 
 in