From 3bcc53bcd6345dc5aa6ddeca949ab59dba6e7590 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 6 Nov 2015 15:25:40 -0800 Subject: 2381 --- 010vm.cc | 2 ++ 030container.cc | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/010vm.cc b/010vm.cc index b4ba23f1..cf46bc65 100644 --- a/010vm.cc +++ b/010vm.cc @@ -275,6 +275,8 @@ type_tree* new_type_tree(const string_tree* properties) { const string& type_name = properties->value; if (contains_key(Type_ordinal, type_name)) result->value = get(Type_ordinal, type_name); + else + result->value = -1; } result->left = new_type_tree(properties->left); result->right = new_type_tree(properties->right); 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 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) -- cgit 1.4.1-2-gfad0