Integrate locale activation fallback diagnostics with 'trace_locales'.
authorballarin
Wed, 28 Aug 2019 19:19:17 +0200
changeset 70622 2fb2e7661e16
parent 70621 1afcfb7fdff4
child 70627 e59a4ae35b88
Integrate locale activation fallback diagnostics with 'trace_locales'.
src/Pure/Isar/expression.ML
src/Pure/Isar/locale.ML
--- a/src/Pure/Isar/expression.ML	Wed Aug 28 08:51:20 2019 +0200
+++ b/src/Pure/Isar/expression.ML	Wed Aug 28 19:19:17 2019 +0200
@@ -396,7 +396,9 @@
         val (inst_morph, _) = inst_morphism params (prfx, inst''') ctxt;
         val ctxt' = Locale.activate_declarations (loc, inst_morph) ctxt2
           handle ERROR msg => if null eqns then error msg else
-            (writeln (msg ^ "\nFalling back to reading rewrites clause first."); ctxt2);
+            (Locale.tracing ctxt1
+             (msg ^ "\nFalling back to reading rewrites clause before activation.");
+             ctxt2);
 
         val attrss = map (apsnd (map (prep_attr ctxt)) o fst) eqns;
         val eqns' = (prep_eqns ctxt' o map snd) eqns;
--- a/src/Pure/Isar/locale.ML	Wed Aug 28 08:51:20 2019 +0200
+++ b/src/Pure/Isar/locale.ML	Wed Aug 28 19:19:17 2019 +0200
@@ -96,6 +96,7 @@
     {source: string, target: string, prefix: (string * bool) list, morphism: morphism,
       pos: Position.T, serial: serial}
   val dest_dependencies: theory list -> theory -> locale_dependency list
+  val tracing : Proof.context -> string -> unit
 end;
 
 structure Locale: LOCALE =
@@ -473,11 +474,12 @@
 val trace_locales =
   Attrib.setup_config_bool (Binding.make ("trace_locales", \<^here>)) (K false);
 
+fun tracing context msg =
+  if Config.get context trace_locales then Output.tracing msg else ();
+  
 fun trace kind (name, morph) context =
-  if Config.get_generic context trace_locales
-  then tracing ("Activating " ^ kind ^ " of " ^
-    (pretty_reg (Context.proof_of context) Morphism.identity (name, morph) |> Pretty.string_of))
-  else ();
+  tracing (Context.proof_of context) ("Activating " ^ kind ^ " of " ^
+    (pretty_reg (Context.proof_of context) Morphism.identity (name, morph) |> Pretty.string_of));
 
 fun activate_syntax_decls (name, morph) context =
   let