about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--040brace.cc8
-rw-r--r--053recipe_header.cc10
2 files changed, 15 insertions, 3 deletions
diff --git a/040brace.cc b/040brace.cc
index 75877dca..4a6bfd10 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -392,7 +392,7 @@ def test1 [
 //   ```
 if (curr.name == "return-if" || curr.name == "reply-if") {
   if (curr.products.empty()) {
-    emit_return_block(result, "break-unless", curr.ingredients);
+    emit_return_block(result, "break-unless", curr);
     curr.clear();
   }
   else {
@@ -408,7 +408,7 @@ if (curr.name == "return-if" || curr.name == "reply-if") {
 //   ```
 if (curr.name == "return-unless" || curr.name == "reply-unless") {
   if (curr.products.empty()) {
-    emit_return_block(result, "break-if", curr.ingredients);
+    emit_return_block(result, "break-if", curr);
     curr.clear();
   }
   else {
@@ -417,7 +417,8 @@ if (curr.name == "return-unless" || curr.name == "reply-unless") {
 }
 
 :(code)
-void emit_return_block(recipe& out, const string& break_command, const vector<reagent>& ingredients) {
+void emit_return_block(recipe& out, const string& break_command, const instruction& inst) {
+  const vector<reagent>& ingredients = inst.ingredients;
   reagent/*copy*/ condition = ingredients.at(0);
   vector<reagent> return_ingredients;
   copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end()));
@@ -438,6 +439,7 @@ void emit_return_block(recipe& out, const string& break_command, const vector<re
   return_inst.operation = get(Recipe_ordinal, "return");
   return_inst.name = "return";
   return_inst.ingredients.swap(return_ingredients);
+  return_inst.original_string = inst.original_string;
   out.steps.push_back(return_inst);
 
   // }
diff --git a/053recipe_header.cc b/053recipe_header.cc
index 2ee10d09..c8904ba3 100644
--- a/053recipe_header.cc
+++ b/053recipe_header.cc
@@ -353,6 +353,16 @@ def add2 x:num, y:num [
 ]
 +error: add2: replied with the wrong number of products at 'return z'
 
+:(scenario recipe_headers_are_checked_against_transformed_instructions)
+% Hide_errors = true;
+def foo -> x:num [
+  local-scope
+  x:num <- copy 0
+  z:bool <- copy 0/false
+  return-if z, z
+]
++error: foo: replied with the wrong type at 'return-if z, z'
+
 :(scenario recipe_headers_check_for_duplicate_names)
 % Hide_errors = true;
 def add2 x:num, x:num -> z:num [