From 054e1b3c251ab81b50b759e08cc16e54c336bfa1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 24 Jul 2015 01:05:59 -0700 Subject: 1833 --- 030container.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to '030container.cc') 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); -- cgit 1.4.1-2-gfad0