about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/030container.cc b/030container.cc
index 46314d00..15a6eb6f 100644
--- a/030container.cc
+++ b/030container.cc
@@ -109,6 +109,7 @@ Recipe_ordinal["get"] = GET;
 case GET: {
   if (SIZE(ingredients) != 2) {
     raise << current_recipe_name() << ": 'get' expects exactly 2 ingredients in '" << current_instruction().to_string() << "'\n" << end();
+    products.resize(1);
     break;
   }
   reagent base = current_instruction().ingredients.at(0);
@@ -116,10 +117,12 @@ case GET: {
   type_ordinal base_type = base.types.at(0);
   if (Type[base_type].kind != container) {
     raise << current_recipe_name () << ": first ingredient of 'get' should be a container, but got " << base.original_string << '\n' << end();
+    products.resize(1);
     break;
   }
   if (!is_literal(current_instruction().ingredients.at(1))) {
     raise << current_recipe_name() << ": second ingredient of 'get' should have type 'offset', but got " << current_instruction().ingredients.at(1).original_string << '\n' << end();
+    products.resize(1);
     break;
   }
   assert(scalar(ingredients.at(1)));
@@ -188,6 +191,7 @@ GET_ADDRESS,
 Recipe_ordinal["get-address"] = GET_ADDRESS;
 :(before "End Primitive Recipe Implementations")
 case GET_ADDRESS: {
+  products.resize(1);
   reagent base = current_instruction().ingredients.at(0);
   long long int base_address = base.value;
   type_ordinal base_type = base.types.at(0);
@@ -203,7 +207,6 @@ case GET_ADDRESS: {
   long long int offset = ingredients.at(1).at(0);
   if (offset < 0 || offset >= SIZE(Type[base_type].elements)) {
     raise << "invalid offset " << offset << " for " << Type[base_type].name << '\n' << end();
-    products.resize(1);
     break;
   }
   long long int result = base_address;
@@ -211,7 +214,6 @@ case GET_ADDRESS: {
     result += size_of(Type[base_type].elements.at(i));
   }
   trace(Primitive_recipe_depth, "run") << "address to copy is " << result << end();
-  products.resize(1);
   products.at(0).push_back(result);
   break;
 }