diff options
-rw-r--r-- | 020run.cc | 2 | ||||
-rw-r--r-- | 032array.cc | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/020run.cc b/020run.cc index 5568b2a4..8ea341e4 100644 --- a/020run.cc +++ b/020run.cc @@ -279,7 +279,7 @@ void write_memory(reagent/*copy*/ x, const vector<double>& data, const int /*onl // End Preprocess write_memory(x, data) if (x.value == 0) return; if (size_mismatch(x, data)) { - raise << maybe(current_recipe_name()) << "size mismatch in storing to '" << x.original_string << "' (" << size_of(x.type) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end(); + raise << maybe(current_recipe_name()) << "size mismatch in storing to '" << x.original_string << "' (" << size_of(x) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end(); return; } // End write_memory(x) Special-cases 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; |