about summary refs log tree commit diff stats
path: root/032array.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-07-11 21:31:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-11 21:31:22 -0700
commit8dccf184feebe1acd2354231e16d464ef6f8251d (patch)
treed07fb386203ac92ff7f703c1a6f4d0cdcd819c3a /032array.cc
parentfe51763cefd9980037b960e6f9afcc8619268fb7 (diff)
downloadmu-8dccf184feebe1acd2354231e16d464ef6f8251d.tar.gz
3110 - better support static arrays in containers
Diffstat (limited to '032array.cc')
-rw-r--r--032array.cc21
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;