diff options
Diffstat (limited to '030container.cc')
-rw-r--r-- | 030container.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/030container.cc b/030container.cc index 2263833c..a345370b 100644 --- a/030container.cc +++ b/030container.cc @@ -83,7 +83,10 @@ if (t.kind == container) { long long int result = 0; for (long long int i = 0; i < SIZE(t.elements); ++i) { // todo: strengthen assertion to disallow mutual type recursion - assert(types.at(0) != t.elements.at(i).at(0)); + if (types.at(0) == t.elements.at(i).at(0)) { + raise << "container " << t.name << " can't include itself as a member\n"; + return 0; + } result += size_of(t.elements.at(i)); } return result; @@ -104,6 +107,10 @@ GET, Recipe_ordinal["get"] = GET; :(before "End Primitive Recipe Implementations") case GET: { + if (ingredients.size() != 2) { + raise << current_recipe_name() << ": 'get' expects exactly 2 ingredients in '" << current_instruction().to_string() << "'\n"; + break; + } reagent base = current_instruction().ingredients.at(0); long long int base_address = base.value; type_ordinal base_type = base.types.at(0); |