about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-24 01:05:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-24 01:05:59 -0700
commit054e1b3c251ab81b50b759e08cc16e54c336bfa1 (patch)
tree75a63869bdb34f1d0fe94d759f0e852948867c00 /030container.cc
parent7a8db77002a2ab90c923dffac18128defe47c177 (diff)
downloadmu-054e1b3c251ab81b50b759e08cc16e54c336bfa1.tar.gz
1833
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc9
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);