about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-13 16:32:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-13 16:32:36 -0700
commit1ad3fe9e6134353362c9a1318b4ba52d3ecc0d75 (patch)
treedf349dea704fca028c8c29c87d6f34f59b706671 /030container.cc
parentdae2fa9688ce7b61ee2a46c0b616543ddbecd889 (diff)
downloadmu-1ad3fe9e6134353362c9a1318b4ba52d3ecc0d75.tar.gz
1988 - handle reagents without types
This can happen if 'canonize' fails. Make sure it doesn't kill mu.

Thanks Caleb Couch.
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/030container.cc b/030container.cc
index 5bc81a5f..ac198929 100644
--- a/030container.cc
+++ b/030container.cc
@@ -134,11 +134,11 @@ case GET: {
     raise << current_recipe_name() << ": tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end();
     break;
   }
-  type_ordinal base_type = base.types.at(0);
-  if (Type[base_type].kind != container) {
+  if (base.types.empty() || Type[base.types.at(0)].kind != container) {
     raise << current_recipe_name () << ": first ingredient of 'get' should be a container, but got " << base.original_string << '\n' << end();
     break;
   }
+  type_ordinal base_type = base.types.at(0);
   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();
     break;
@@ -214,11 +214,11 @@ case GET_ADDRESS: {
     raise << current_recipe_name() << ": tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end();
     break;
   }
-  type_ordinal base_type = base.types.at(0);
-  if (Type[base_type].kind != container) {
+  if (base.types.empty() || Type[base.types.at(0)].kind != container) {
     raise << current_recipe_name () << ": first ingredient of 'get-address' should be a container, but got " << base.original_string << '\n' << end();
     break;
   }
+  type_ordinal base_type = base.types.at(0);
   if (!is_literal(current_instruction().ingredients.at(1))) {
     raise << current_recipe_name() << ": second ingredient of 'get-address' should have type 'offset', but got " << current_instruction().ingredients.at(1).original_string << '\n' << end();
     break;