about summary refs log tree commit diff stats
path: root/034address.cc
diff options
context:
space:
mode:
Diffstat (limited to '034address.cc')
-rw-r--r--034address.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/034address.cc b/034address.cc
index c8a171ec..27f7af87 100644
--- a/034address.cc
+++ b/034address.cc
@@ -277,6 +277,7 @@ void transform_new_to_allocate(const recipe_ordinal r) {
     instruction& inst = get(Recipe, r).steps.at(i);
     // Convert 'new' To 'allocate'
     if (inst.name == "new") {
+      if (inst.ingredients.empty()) return;  // error raised elsewhere
       inst.operation = ALLOCATE;
       type_tree* type = new_type_tree(inst.ingredients.at(0).name);
       inst.ingredients.at(0).set_value(size_of(type));
@@ -425,3 +426,10 @@ def main [
 ]
 +new: routine allocated memory from 1000 to 1003
 +new: routine allocated memory from 1003 to 1006
+
+:(scenario new_without_ingredient)
+% Hide_errors = true;
+def main [
+  1:address:number <- new  # missing ingredient
+]
++error: main: 'new' requires one or two ingredients, but got '1:address:number <- new'