diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-05-20 23:45:03 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-05-20 23:45:03 -0700 |
commit | 0d21947757a1e8ca4f5c94617fd94753f6d3de56 (patch) | |
tree | b85e01af2bc2dec2b7becd5114ce176d6c098459 /032array.cc | |
parent | e0659ab38fa6315a0b83a2757582f49976ab38fa (diff) | |
download | mu-0d21947757a1e8ca4f5c94617fd94753f6d3de56.tar.gz |
2992
Raise an error if a 'put' or 'put-index' doesn't match ingredient and product. That wouldn't do what you would expect.
Diffstat (limited to '032array.cc')
-rw-r--r-- | 032array.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/032array.cc b/032array.cc index 016e9d19..8d08fdc2 100644 --- a/032array.cc +++ b/032array.cc @@ -355,6 +355,10 @@ case PUT_INDEX: { raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << 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-index' 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") @@ -419,6 +423,16 @@ def main [ ] +error: main: invalid index -1 +:(scenario put_index_product_error) +% Hide_errors = true; +def main [ + local-scope + load-ingredients + 1:array:number:3 <- create-array + 4:array:number:3 <- put-index 1:array:number:3, 0, 34 +] ++error: main: product of 'put-index' must be first ingredient '1:array:number:3', but got '4:array:number:3' + //:: compute the length of an array :(scenario array_length) |