From f7d3dc0eea180a6e5c233fdc493ad8f6cf1022e4 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 25 May 2018 12:25:13 -0700 Subject: 4247 --- 024jump.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to '024jump.cc') diff --git a/024jump.cc b/024jump.cc index 748b2405..37011290 100644 --- a/024jump.cc +++ b/024jump.cc @@ -23,6 +23,10 @@ case JUMP: { raise << maybe(get(Recipe, r).name) << "first ingredient of '" << to_original_string(inst) << "' should be a label or offset, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end(); break; } + if (!inst.products.empty()) { + raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end(); + break; + } break; } :(before "End Primitive Recipe Implementations") @@ -51,6 +55,13 @@ def main [ +run: jump {-2: "offset"} +run: jump {3: "offset"} +:(scenario jump_takes_no_products) +% Hide_errors = true; +def main [ + 1:num <- jump 1 +] ++error: main: 'jump' instructions write no products + :(before "End Primitive Recipe Declarations") JUMP_IF, :(before "End Primitive Recipe Numbers") @@ -69,6 +80,10 @@ case JUMP_IF: { raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end(); break; } + if (!inst.products.empty()) { + raise << maybe(get(Recipe, r).name) << "'jump-if' instructions write no products\n" << end(); + break; + } // End JUMP_IF Checks break; } @@ -125,6 +140,10 @@ case JUMP_UNLESS: { raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end(); break; } + if (!inst.products.empty()) { + raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end(); + break; + } // End JUMP_UNLESS Checks break; } -- cgit 1.4.1-2-gfad0