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.
36 lines
1.4 KiB
Plaintext
36 lines
1.4 KiB
Plaintext
// Passing a slice of a `def`-dimensioned array
|
|
// (`take(buf[1:])` on `[MAX]T`) as a call argument must resolve the default-hi
|
|
// length from the type table, the N_SLICE arg-push member of the def-dim
|
|
// family, migrated from test/wcc/989_defdim_argslice_run.c (#56 c4). pushargsrev's
|
|
// N_SLICE default-hi arms (local / global) only handled an N_INTLIT dim, so a
|
|
// plain `[MAX]u8` base emitted nothing and the pushed slice header's len word
|
|
// was left stale -- the callee read garbage (ww 135 local / 255 global). The
|
|
// fix reads alen from the stamped array tinfo (rule-13) in both arg-push arms.
|
|
// `take` returns s.len, so the asserted 4 IS the pushed-header length contract;
|
|
// the litctrl row pins the N_INTLIT path so the new else-arm can't perturb it.
|
|
// T2 (test-lang-byteid) keeps the cs==ww net the .c twin's run-compare gave.
|
|
|
|
package defdim_argslice_test;
|
|
|
|
def MAX: i32 = 5;
|
|
let g: [MAX]u8 = [1, 2, 3, 4, 5];
|
|
|
|
fn take(s: []u8) i32 = { return s.len: i32; };
|
|
|
|
@test fn local_argslice() void = {
|
|
// local def-dim base: take(buf[1:]) sees len 5-1 = 4.
|
|
let buf: [MAX]u8 = [1, 2, 3, 4, 5];
|
|
assert(take(buf[1:]) == 4);
|
|
};
|
|
|
|
@test fn global_argslice() void = {
|
|
// global def-dim base: take(g[1:]) sees len 4.
|
|
assert(take(g[1:]) == 4);
|
|
};
|
|
|
|
@test fn litctrl_argslice() void = {
|
|
// literal-dim control: the N_INTLIT arm stays correct (no regress).
|
|
let buf: [5]u8 = [1, 2, 3, 4, 5];
|
|
assert(take(buf[1:]) == 4);
|
|
};
|