about summary refs log tree commit diff stats
path: root/042name.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-26 21:50:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-26 21:50:54 -0800
commit1e38eee5db71d551ee2dbddb35d187489e372c8c (patch)
tree307af6dbbcb7c890f162b3102ac71ffad99a4e77 /042name.cc
parent947f06fb5569007a5a3c444683794427c72cef52 (diff)
downloadmu-1e38eee5db71d551ee2dbddb35d187489e372c8c.tar.gz
2718 - stop crashing on unknown space
I'm going to stop wasting precious first-line characters on 'bugfix:'.
It's going to be all bugfixes for a while I think.
Diffstat (limited to '042name.cc')
-rw-r--r--042name.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/042name.cc b/042name.cc
index e618ac89..f7eba9e0 100644
--- a/042name.cc
+++ b/042name.cc
@@ -51,7 +51,14 @@ void transform_names(const recipe_ordinal r) {
       if (!already_transformed(inst.ingredients.at(in), names)) {
         raise << maybe(caller.name) << "use before set: " << inst.ingredients.at(in).name << '\n' << end();
       }
-      inst.ingredients.at(in).set_value(lookup_name(inst.ingredients.at(in), r));
+      long long int v = lookup_name(inst.ingredients.at(in), r);
+      if (v >= 0) {
+        inst.ingredients.at(in).set_value(v);
+      }
+      else {
+        raise << maybe(caller.name) << "can't find a place to store " << inst.ingredients.at(in).name << '\n' << end();
+        return;
+      }
     }
     for (long long int out = 0; out < SIZE(inst.products); ++out) {
       if (is_disqualified(inst.products.at(out), inst, caller.name)) continue;
@@ -63,7 +70,14 @@ void transform_names(const recipe_ordinal r) {
         names[inst.products.at(out).name] = curr_idx;
         curr_idx += size_of(inst.products.at(out));
       }
-      inst.products.at(out).set_value(lookup_name(inst.products.at(out), r));
+      long long int v = lookup_name(inst.products.at(out), r);
+      if (v >= 0) {
+        inst.products.at(out).set_value(v);
+      }
+      else {
+        raise << maybe(caller.name) << "can't find a place to store " << inst.products.at(out).name << '\n' << end();
+        return;
+      }
     }
   }
   if (names_used && numeric_locations_used)