about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-06 15:25:40 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-06 15:25:40 -0800
commit3bcc53bcd6345dc5aa6ddeca949ab59dba6e7590 (patch)
treecfb294ed9bcc75d88afd45eb09383a4bfca9bbeb /030container.cc
parentc157066cab02f91b2d5e53dbec09151936538578 (diff)
downloadmu-3bcc53bcd6345dc5aa6ddeca949ab59dba6e7590.tar.gz
2381
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/030container.cc b/030container.cc
index ae6f590c..5c19c4c8 100644
--- a/030container.cc
+++ b/030container.cc
@@ -83,6 +83,10 @@ recipe main [
 +mem: storing 0 in location 7
 
 :(before "End size_of(type) Cases")
+if (type->value == -1) {
+  // error value, but we'll raise it elsewhere
+  return 1;
+}
 if (type->value == 0) {
   assert(!type->left && !type->right);
   return 1;
@@ -458,6 +462,7 @@ vector<type_ordinal> recently_added_types;
 recently_added_types.clear();
 :(before "End Setup")  //: for tests
 for (long long int i = 0; i < SIZE(recently_added_types); ++i) {
+  if (!contains_key(Type, recently_added_types.at(i))) continue;
   Type_ordinal.erase(get(Type, recently_added_types.at(i)).name);
   // todo: why do I explicitly need to provide this?
   for (long long int j = 0; j < SIZE(Type.at(recently_added_types.at(i)).elements); ++j) {
@@ -530,11 +535,14 @@ void check_invalid_types(const recipe_ordinal r) {
 void check_invalid_types(const type_tree* type, const string& block, const string& name) {
   if (!type) return;  // will throw a more precise error elsewhere
   // End Container Type Checks
-  if (type->value && (!contains_key(Type, type->value) || get(Type, type->value).name.empty())) {
-    raise_error << block << "unknown type in " << name << '\n' << end();
+  if (type->value == 0) {
+    assert(!type->left && !type->right);
+    return;
   }
-  if (type->left) check_invalid_types(type->left, block, name);
-  if (type->right) check_invalid_types(type->right, block, name);
+  if (!contains_key(Type, type->value))
+    raise_error << block << "unknown type in " << name << '\n' << end();
+  check_invalid_types(type->left, block, name);
+  check_invalid_types(type->right, block, name);
 }
 
 :(scenario container_unknown_field)