From 0d21947757a1e8ca4f5c94617fd94753f6d3de56 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 20 May 2016 23:45:03 -0700 Subject: 2992 Raise an error if a 'put' or 'put-index' doesn't match ingredient and product. That wouldn't do what you would expect. --- 030container.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to '030container.cc') diff --git a/030container.cc b/030container.cc index 6bf8bbdc..8c570498 100644 --- a/030container.cc +++ b/030container.cc @@ -435,6 +435,10 @@ case PUT: { raise << maybe(get(Recipe, r).name) << "'put " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); break; } + if (!inst.products.empty() && inst.products.at(0).name != inst.ingredients.at(0).name) { + raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); + break; + } break; } :(before "End Primitive Recipe Implementations") @@ -461,6 +465,16 @@ case PUT: { goto finish_instruction; } +:(scenario put_product_error) +% Hide_errors = true; +def main [ + local-scope + load-ingredients + 1:point <- merge 34, 35 + 3:point <- put 1:point, x:offset, 36 +] ++error: main: product of 'put' must be first ingredient '1:point', but got '3:point' + //:: Allow containers to be defined in mu code. :(scenarios load) -- cgit 1.4.1-2-gfad0