diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-25 00:20:35 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-25 00:23:15 -0700 |
commit | c5e965d87fe2ef50ac70722eea73e89095b9178d (patch) | |
tree | 9be8da3096747e6bd2542e5d44e97c12caf254b7 /011load.cc | |
parent | 35064671ef90ec6e35eafd9b15363058bf4f23f4 (diff) | |
download | mu-c5e965d87fe2ef50ac70722eea73e89095b9178d.tar.gz |
1845 - never ever redefine the scenario's recipe
A couple of times now I've accidentally named a scenario the same thing as a recipe inside it that I define using 'run' or something. The resulting infinite loop is invariably non-trivial to debug.
Diffstat (limited to '011load.cc')
-rw-r--r-- | 011load.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/011load.cc b/011load.cc index 9142429c..7135b548 100644 --- a/011load.cc +++ b/011load.cc @@ -33,7 +33,10 @@ vector<recipe_ordinal> load(istream& in) { if (Recipe_ordinal.find(recipe_name) == Recipe_ordinal.end()) { Recipe_ordinal[recipe_name] = Next_recipe_ordinal++; } - // Warn On Redefinition + if (warn_on_redefine(recipe_name) + && Recipe.find(Recipe_ordinal[recipe_name]) != Recipe.end()) { + raise << "redefining recipe " << Recipe[Recipe_ordinal[recipe_name]].name << "\n" << end(); + } // 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 @@ -204,10 +207,10 @@ void skip_comma(istream& in) { 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" << end(); +:(code) +bool warn_on_redefine(const string& recipe_name) { + if (Hide_redefine_warnings) return false; + return true; } // for debugging |