diff --git a/test/wcc/684_arr_infer_len.c b/test/wcc/684_arr_infer_len.c index 56af61fa..791aa4f6 100644 --- a/test/wcc/684_arr_infer_len.c +++ b/test/wcc/684_arr_infer_len.c @@ -41,6 +41,9 @@ * mod_str_len | global [_]str=["a","b","c"], x.len | 3 * local_u8_len | local [_]u8=[1..5], x.len | 5 * local_u8_elem | local, x[4] | 5 + * local_one_len | local [_]int=[7], x.len (1-elem edge)| 1 + * mod_one_len | global [_]int=[7], x.len | 1 + * mod_one_elem | global, x[0] | 7 */ #include #include @@ -132,6 +135,33 @@ static const struct row rows[] = { "\treturn x[4]: i32;\n" "};\n", 5 }, + + /* 1-element edge — the minimal non-empty count; under the old + * collapse-to-0 bug `.len` reads 0, not 1, so this row also fails + * the mutation. */ + { "local_one_len", + "package main;\n" + "export fn main() i32 = {\n" + "\tlet x: [_]int = [7];\n" + "\treturn x.len: i32;\n" + "};\n", + 1 }, + + { "mod_one_len", + "package main;\n" + "let x: [_]int = [7];\n" + "export fn main() i32 = {\n" + "\treturn x.len: i32;\n" + "};\n", + 1 }, + + { "mod_one_elem", + "package main;\n" + "let x: [_]int = [7];\n" + "export fn main() i32 = {\n" + "\treturn x[0]: i32;\n" + "};\n", + 7 }, }; /* `[_]T` that can't infer its length — both stages must FAIL the build