From 8199d6cdadc21b7b70a75a98198c212ee715b41b Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 3 Jun 2026 18:53:44 +0900 Subject: [PATCH] test/684: add 1-element [_] edge + module element read-back rows The reviewer flagged two gaps in the #7 coverage: no minimal non-empty count (a 1-element [_] is the boundary the element-counter must still get right) and no module-level array element read-back (only .len was checked at module scope). Add local_one_len / mod_one_len / mod_one_elem. Both still mutation-resistant: the old collapse-to-0 reads .len as 0, not 1, so the new len rows fail it too. 42/42 dual-stage + byte-id. --- test/wcc/684_arr_infer_len.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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