From 5e320aa049bc1d5ad78eec23be0127f4a8d6ec3d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 21 May 2017 22:19:28 -0700 Subject: 3876 Thanks Ella Couch for reporting this issue. --- 053recipe_header.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to '053recipe_header.cc') diff --git a/053recipe_header.cc b/053recipe_header.cc index d9495f46..9128f3bb 100644 --- a/053recipe_header.cc +++ b/053recipe_header.cc @@ -499,14 +499,15 @@ void fill_in_return_ingredients(const recipe_ordinal r) { add_header_products(inst, caller_recipe); } // fall through return - if (caller_recipe.steps.empty()) return; // error will be raised elsewhere if there's a product in the header; just give up - const instruction& final_instruction = caller_recipe.steps.at(SIZE(caller_recipe.steps)-1); - if (final_instruction.name != "reply" && final_instruction.name != "return") { - instruction inst; - inst.name = "return"; - add_header_products(inst, caller_recipe); - caller_recipe.steps.push_back(inst); + if (!caller_recipe.steps.empty()) { + const instruction& final_instruction = caller_recipe.steps.at(SIZE(caller_recipe.steps)-1); + if (final_instruction.name == "reply" || final_instruction.name == "return") + return; } + instruction inst; + inst.name = "return"; + add_header_products(inst, caller_recipe); + caller_recipe.steps.push_back(inst); } void add_header_products(instruction& inst, const recipe& caller_recipe) { @@ -565,6 +566,12 @@ def add2 x:num, y:num -> z:num [ -transform: instruction: return z:num +mem: storing 8 in location 1 +:(scenario return_causes_error_in_empty_recipe) +% Hide_errors = true; +def foo -> x:num [ +] ++error: foo: tried to read ingredient 'x' in 'return x:num' but it hasn't been written to yet + :(scenario return_after_conditional_return_based_on_header) def main [ 1:num/raw <- add2 3, 5 -- cgit 1.4.1-2-gfad0 den' name='id' value='c2aa585615d35186fbf8ada94f8974bcb386ce8d'/>
path: root/themes/boothj5_slack
blob: d1546d055ae1b4b6fd037a637db9cd1fced6ea4f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17