about summary refs log tree commit diff stats
path: root/040brace.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-24 20:25:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-24 20:25:37 -0700
commite85cb85b68cb844484bf842a5837a72869942a17 (patch)
treebeb18593ca76bab14a034c422f98730fe97382aa /040brace.cc
parent0cfc678fdc686c0216ea238ff197e0e54e4a3f8c (diff)
downloadmu-e85cb85b68cb844484bf842a5837a72869942a17.tar.gz
2075
Thanks Caleb Couch for bugfixes 2072-2075.
Diffstat (limited to '040brace.cc')
-rw-r--r--040brace.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/040brace.cc b/040brace.cc
index 7819cd58..9615ba58 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -75,6 +75,13 @@ void transform_braces(const recipe_ordinal r) {
       trace("after-brace") << inst.name << " ..." << end();
       continue;
     }
+    // check for errors
+    if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) {
+      if (inst.ingredients.empty()) {
+        raise << inst.name << " expects 1 or 2 ingredients, but got none\n" << end();
+        continue;
+      }
+    }
     // update instruction operation
     if (inst.name.find("-if") != string::npos)
       inst.operation = Recipe_ordinal["jump-if"];
@@ -363,3 +370,12 @@ recipe main [
   break
 ]
 +warn: break needs a '{' before
+
+:(scenario break_conditional_without_ingredient_warns)
+% Hide_warnings = true;
+recipe main [
+  {
+    break-if
+  }
+]
++warn: break-if expects 1 or 2 ingredients, but got none