From 91ec4681cf42d608221ef3fdbc371fb0836f5303 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 4 May 2016 13:57:32 -0700 Subject: 2899 --- 032array.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to '032array.cc') diff --git a/032array.cc b/032array.cc index 3d93e84d..485f403f 100644 --- a/032array.cc +++ b/032array.cc @@ -239,7 +239,9 @@ type_tree* copy_array_element(const type_tree* type) { } int array_length(const reagent& x) { - if (x.type->right->right) { + if (x.type->right->right && !x.type->right->right->right // exactly 3 types + && is_integer(x.type->right->right->name)) { // third 'type' is a number + // get size from type return to_integer(x.type->right->right->name); } // this should never happen at transform time @@ -247,6 +249,16 @@ int array_length(const reagent& x) { return get_or_insert(Memory, x.value); } +void test_array_length_compound() { + put(Memory, 1, 3); + put(Memory, 2, 14); + put(Memory, 3, 15); + put(Memory, 4, 16); + reagent x("1:array:address:number"); // 3 types, but not a static array + populate_value(x); + CHECK_EQ(array_length(x), 3); +} + :(scenario index_out_of_bounds) % Hide_errors = true; def main [ -- cgit 1.4.1-2-gfad0