// `.len` field-read on an array whose dimension is a // `def` constant (`[MAX]T`) must resolve the length from the type table, the // cgdot sibling of the #21 cgslice fix, migrated from // test/wcc/989_defdim_field_run.c (#56). A `def MAX` dim arrives as a // non-literal node; wwstage's cgdot `.len` arms (local / let-global / def) + // letemitsize only handled an N_INTLIT dim, so `.len` folded to MOVQ $0 (ww // returned 0 where cstage reads the resolved bu->alen). The fix reads alen from // the stamped array tinfo (rule-13) in each arm. cstage was always correct; T2 // (test-lang-byteid) keeps the cs==ww net the .c twin's run-compare provided. package defdim_field_test; def MAX: i32 = 5; let g: [MAX]u8 = [1, 2, 3, 4, 5]; def A: [MAX]u8 = [1, 2, 3, 4, 5]; @test fn local_len() void = { // local [MAX]u8 — the cgdot local arm; pre-fix ww folded to 0. let buf: [MAX]u8 = [1, 2, 3, 4, 5]; assert(buf.len: i32 == 5); }; @test fn global_len() void = { // let-global [MAX]u8 — the cgdot let-global arm. assert(g.len: i32 == 5); }; @test fn defarr_len() void = { // def [MAX]u8 constant — the cgdot def arm. assert(A.len: i32 == 5); }; @test fn sum_len() void = { // all three arms in one fn (the .c `sum` row): 5 + 5 + 5 = 15. let buf: [MAX]u8 = [1, 2, 3, 4, 5]; assert((buf.len + g.len + A.len): i32 == 15); };