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.
60 lines
1.6 KiB
Plaintext
60 lines
1.6 KiB
Plaintext
// #25/#31: a one-step array-LITERAL initialiser for a SLICE
|
|
// local (`let xs: []T = [..]`). Migrated from test/wcc/953_arrlit_slice_run.c
|
|
// (value rows; cs==ww byte-id rides T2). Reject rows, including the
|
|
// stage-asymmetric assignment diagnostic, live under test/wcc/data/.
|
|
//
|
|
// #31 (silent cs!=ww): the borrow wrapped the un-addressable arrlit directly,
|
|
// so .ptr pointed at garbage (xs[1] returned 1, not 20; []u8/[]str SEGV). #25
|
|
// (over-strict): bare-int-width / str elements rejected. The fix re-stamps the
|
|
// arrlit [count]T and materialises a fresh per-borrow stack slot. multi_live is
|
|
// the SOUNDNESS pin: a shared backing slot would alias the two borrows (4+4=8).
|
|
|
|
package arrlit_slice_test;
|
|
|
|
@test fn i32_sum() void = {
|
|
let xs: []i32 = [10, 20, 30];
|
|
assert(xs[0] + xs[1] + xs[2] == 60);
|
|
};
|
|
|
|
@test fn i32_idx() void = {
|
|
let xs: []i32 = [10, 20, 30];
|
|
assert(xs[1] == 20);
|
|
};
|
|
|
|
@test fn u8_coerce() void = {
|
|
let zs: []u8 = [1, 2, 3];
|
|
assert(zs[0]: i32 + zs[1]: i32 + zs[2]: i32 == 6);
|
|
};
|
|
|
|
@test fn u8_typed() void = {
|
|
let xs: []u8 = [10u8, 20u8, 30u8];
|
|
assert(xs[2]: i32 == 30);
|
|
};
|
|
|
|
@test fn i64_stride() void = {
|
|
let xs: []i64 = [7i64, 42i64];
|
|
assert(xs[1] == 42);
|
|
};
|
|
|
|
@test fn str_read() void = {
|
|
let ys: []str = ["ab", "c"];
|
|
assert(ys[0].len: i32 * 10 + ys[1].len: i32 == 21);
|
|
};
|
|
|
|
@test fn len_read() void = {
|
|
let xs: []i32 = [10, 20, 30];
|
|
assert(xs.len == 3);
|
|
};
|
|
|
|
@test fn multi_live() void = {
|
|
let xs: []i32 = [1, 2, 3];
|
|
let ys: []i32 = [4, 5];
|
|
assert(xs[0] + ys[0] == 5);
|
|
};
|
|
|
|
@test fn borrow_mut() void = {
|
|
let xs: []i32 = [1, 2, 3];
|
|
xs[1] = 99;
|
|
assert(xs[1] == 99);
|
|
};
|