Every section banner dies (103 -> 0) across test/lang, the observer suites, the C carriers, and the five comment-heavy corpus fixtures; banner provenance (#N cites, carrier numbers, repair-cluster labels) folded into headers or adjacent WHY comments. Narration deleted; row provenance, ref cites, divergence pins, and layout contracts kept (fwd-ref decl-order guards and bootstrap-gate corpus rationale restored where the sweep over-cut). Comment-only proven: all 3742 wwbuild workdir .s byte-identical before/after; test-commit and test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
// `.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);
|
|
};
|