From 8dccf184feebe1acd2354231e16d464ef6f8251d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 11 Jul 2016 21:31:22 -0700 Subject: 3110 - better support static arrays in containers --- 032array.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to '032array.cc') diff --git a/032array.cc b/032array.cc index 9fe69b5c..7f918870 100644 --- a/032array.cc +++ b/032array.cc @@ -112,7 +112,7 @@ if (x.type && x.type->value == get(Type_ordinal, "array")) return false; //: arrays are disallowed inside containers unless their length is fixed in //: advance -:(scenario container_contains_array) +:(scenario container_permits_static_array_element) container foo [ x:array:number:3 ] @@ -125,6 +125,25 @@ container foo [ ] +error: container 'foo' cannot determine size of element 'x' +//: disable the size mismatch check for 'merge' instructions since containers +//: can contain arrays, and since we already do plenty of checking for them +:(before "End size_mismatch(x) Cases") +if (current_call().running_step_index < SIZE(get(Recipe, current_call().running_recipe).steps) + && current_instruction().operation == MERGE) { + return false; +} + +:(scenario merge_static_array_into_container) +container foo [ + x:number + y:array:number:3 +] +def main [ + 1:array:number:3 <- create-array + 10:foo <- merge 34, 1:array:number:3 +] +# no errors + :(before "End Load Container Element Definition") { const type_tree* type = info.elements.back().type; -- cgit 1.4.1-2-gfad0