about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--011load.cc17
-rw-r--r--081run_interactive.cc8
2 files changed, 16 insertions, 9 deletions
diff --git a/011load.cc b/011load.cc
index 0ae42cf5..7ce8e25f 100644
--- a/011load.cc
+++ b/011load.cc
@@ -33,9 +33,7 @@ vector<recipe_ordinal> load(istream& in) {
       if (Recipe_ordinal.find(recipe_name) == Recipe_ordinal.end()) {
         Recipe_ordinal[recipe_name] = Next_recipe_ordinal++;
       }
-      if (Recipe.find(Recipe_ordinal[recipe_name]) != Recipe.end()) {
-        if (!Loading_interactive) raise << "redefining recipe " << Recipe[Recipe_ordinal[recipe_name]].name << "\n";
-      }
+      // Warn On Redefinition
       // todo: save user-defined recipes to mu's memory
       Recipe[Recipe_ordinal[recipe_name]] = slurp_recipe(in);
 //?       cerr << Recipe_ordinal[recipe_name] << ": " << recipe_name << '\n'; //? 1
@@ -196,6 +194,19 @@ void skip_comma(istream& in) {
   skip_whitespace(in);
 }
 
+//: Warn if a recipe gets redefined, because large codebases can accidentally
+//: step on their own toes. But there'll be many occasions later where
+//: we'll want to disable the warnings.
+:(before "End Globals")
+bool Hide_redefine_warnings = false;
+:(before "End Setup")
+Hide_redefine_warnings = false;
+:(after "Warn On Redefinition")
+if (!Hide_redefine_warnings
+    && Recipe.find(Recipe_ordinal[recipe_name]) != Recipe.end()) {
+  raise << "redefining recipe " << Recipe[Recipe_ordinal[recipe_name]].name << "\n";
+}
+
 // for debugging
 :(before "End Globals")
 bool Show_rest_of_stream = false;
diff --git a/081run_interactive.cc b/081run_interactive.cc
index f7d049ff..36a0ec1a 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -257,10 +257,6 @@ long long int warnings_from_trace() {
 
 //: simpler version of run-interactive: doesn't do any running, just loads
 //: recipes and reports warnings.
-:(before "End Globals")
-bool Loading_interactive = false;
-:(before "End Setup")
-Loading_interactive = false;
 :(before "End Primitive Recipe Declarations")
 RELOAD,
 :(before "End Primitive Recipe Numbers")
@@ -273,13 +269,13 @@ case RELOAD: {
     Trace_stream = new trace_stream;
     Trace_stream->collect_layer = "warn";
   }
-  Loading_interactive = true;
   Hide_warnings = true;
+  Hide_redefine_warnings = true;
   load(read_mu_string(ingredients.at(0).at(0)));
   transform_all();
   Trace_stream->newline();  // flush trace
+  Hide_redefine_warnings = false;
   Hide_warnings = false;
-  Loading_interactive = false;
   products.resize(1);
   products.at(0).push_back(warnings_from_trace());
   if (Trace_stream->collect_layer == "warn") {