diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 09:16:26 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 12:14:09 -0700 |
commit | 04a2a2928c795013fc28e9c6ac41edf51162349b (patch) | |
tree | 085082719b21454b9b3f7c91d4dfc3cf0acb32dd | |
parent | 8bafc90dfda6cd170343ad1d7351d418f38189ae (diff) | |
download | mu-04a2a2928c795013fc28e9c6ac41edf51162349b.tar.gz |
3610 - bugfix in type-checking 'call' instructions
Thanks Rebecca Allard for running into this. The test is in layer 13 even though the code that regressed was fixed in layer 71, because the test was working as-is in earlier layers.
-rw-r--r-- | 013update_operation.cc | 7 | ||||
-rw-r--r-- | 071recipe.cc | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/013update_operation.cc b/013update_operation.cc index 418b3563..10b29714 100644 --- a/013update_operation.cc +++ b/013update_operation.cc @@ -25,3 +25,10 @@ void update_instruction_operations(const recipe_ordinal r) { string maybe(string s) { return s + ": "; } + +:(scenario missing_arrow) +% Hide_errors = true; +def main [ + 1:number , copy 0 # typo: ',' instead of '<-' +] ++error: main: instruction '1:number' has no recipe diff --git a/071recipe.cc b/071recipe.cc index e08f75db..345057d5 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -160,9 +160,10 @@ void check_indirect_calls_against_header(const recipe_ordinal r) { const recipe& caller = get(Recipe, r); for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); - if (inst.ingredients.empty()) continue; // if indirect call, error raised above + if (!is_indirect_call(inst.operation)) continue; + if (inst.ingredients.empty()) continue; // error raised above const reagent& callee = inst.ingredients.at(0); - if (!is_mu_recipe(callee)) continue; // if indirect call, error raised above + if (!is_mu_recipe(callee)) continue; // error raised above const recipe callee_header = is_literal(callee) ? get(Recipe, callee.value) : from_reagent(inst.ingredients.at(0)); if (!callee_header.has_header) continue; if (is_indirect_call_with_ingredients(inst.operation)) { @@ -181,6 +182,10 @@ void check_indirect_calls_against_header(const recipe_ordinal r) { } } +bool is_indirect_call(const recipe_ordinal r) { + return is_indirect_call_with_ingredients(r) || is_indirect_call_with_products(r); +} + bool is_indirect_call_with_ingredients(const recipe_ordinal r) { if (r == CALL) return true; // End is_indirect_call_with_ingredients Special-cases |