Files
ww/test/lang/structlit_arrfield_test.ww
Hojun-Cho 83f5956df2 test: banner purge + WHY-only comment sweep (rule 8)
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.
2026-08-08 21:40:23 +09:00

35 lines
1.2 KiB
Plaintext

// Struct array-field init + read (global let/def and
// local lit). Migrated from test/wcc/949_structlit_arrfield_run.c (#249). BUG B:
// reading a [4]u8 field of a module-global struct SEGFAULTed on wwstage; BUG A:
// a local struct-lit array field fell to the scalar tail and dropped every
// element but the first. Fix = cg_structlit_fill array arm + def_isstructdef
// LOAD widening (ADDQ $field_off). cstage build+run was T1; cs==ww .s byte-id
// rides T2 (test-lang-byteid). The def row has a [3]u8 pad ahead of encmap, so
// the read exercises a non-zero field offset (the base64 std_encoding shape).
package structlit_arrfield_test;
type e1 = struct { encmap: [4]u8 };
let GE: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
type e2 = struct { pad: [3]u8, encmap: [4]u8 };
def GD: e2 = e2 { pad = [9u8, 9u8, 9u8], encmap = [65u8, 66u8, 67u8, 68u8] };
@test fn global_let_read() void = {
assert(GE.encmap[0]: i32 == 65);
};
@test fn global_def_read_off() void = {
assert(GD.encmap[2]: i32 == 67);
};
@test fn local_lit_read0() void = {
let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
assert(g.encmap[0]: i32 == 65);
};
@test fn local_lit_read3() void = {
let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
assert(g.encmap[3]: i32 == 68);
};