diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-11 21:31:22 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-11 21:31:22 -0700 |
commit | 8dccf184feebe1acd2354231e16d464ef6f8251d (patch) | |
tree | d07fb386203ac92ff7f703c1a6f4d0cdcd819c3a /032array.cc | |
parent | fe51763cefd9980037b960e6f9afcc8619268fb7 (diff) | |
download | mu-8dccf184feebe1acd2354231e16d464ef6f8251d.tar.gz |
3110 - better support static arrays in containers
Diffstat (limited to '032array.cc')
-rw-r--r-- | 032array.cc | 21 |
1 files changed, 20 insertions, 1 deletions
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; |