w6c: resolve ptr-to-array and slice-element aggregate sources (task #6 residue)

The two loud siblings filed in d3822d77: (a) an auto-deref *[N]T
indexed base (hs[k].result) failed cgplaceaddr's N_INDEX arm, which
knew only TY_SLICE/TY_ARRAY bases — add the one-pointer hop (the
(*hs)[k] form made implicit; load shape is the slice .ptr word's);
(b) a bare slice-element aggregate source (use(sl[k])) fell off
aggarg_srcaddr's ident-array-only N_INDEX arm into the #271 loud
stop — route the miss through the same cgplaceaddr fallback the
N_DOT arm uses. Both stages, byte-identical (probe matrix: let-copy,
field-assign, call-arg, return, indexed-store all IDENT).

After this, every ADDRESSABLE aggregate source resolves: ident
(local/module-let), deref, dot-chain, and index over array/slice/
ptr-array spines recurse through cgplaceaddr; the remaining loud
paths are rvalue sources (#40 family) and the #274 const-def arg,
both documented divergences. 8 rows added to idxdot_aggcopy_test.
This commit is contained in:
2026-08-08 19:08:19 +09:00
parent cf69cf2f06
commit 84206ff4ed
3 changed files with 120 additions and 11 deletions

View File

@@ -131,3 +131,86 @@ fn pickresult(hs: *[4]handle, k: i64) inner = {
assert(hs[0].result.a == 40);
assert(hs[0].result.b == 41);
};
// task #6 siblings (the d3822d77 loud residue): a *[N]T indexed base
// auto-derefs through cgplaceaddr's pointer hop, and a bare slice
// element rides aggarg_srcaddr's place-resolver fallback.
@test fn ptrbaseletcopy() void = {
let hs: [4]handle = mk();
let hp: *[4]handle = &hs;
let k: i64 = 2;
let r: inner = hp[k].result;
assert(r.a == 11);
assert(r.b == 31);
};
@test fn ptrbasecallarg() void = {
let hs: [4]handle = mk();
let hp: *[4]handle = &hs;
let k: i64 = 2;
assert(use(hp[k].result) == 42);
};
fn pickptr(hp: *[4]handle, k: i64) inner = {
return hp[k].result;
};
@test fn ptrbasereturn() void = {
let hs: [4]handle = mk();
let r: inner = pickptr(&hs, 2);
assert(r.a == 11);
assert(r.b == 31);
};
@test fn ptrbasefieldassign() void = {
let hs: [4]handle = mk();
let hp: *[4]handle = &hs;
let k: i64 = 2;
let g: bag;
g.n = 0;
g.res = hp[k].result;
assert(g.res.a == 11);
assert(g.res.b == 31);
};
@test fn sliceelemletcopy() void = {
let hs: [4]handle = mk();
let sl: []handle = hs[0:4];
let k: i64 = 2;
let e: handle = sl[k];
assert(e.id == 9);
assert(e.result.a == 11);
};
@test fn sliceelemcallarg() void = {
let hs: [4]handle = mk();
let sl: []handle = hs[0:4];
let k: i64 = 2;
assert(usehandle(sl[k]) == 51);
};
fn usehandle(h: handle) i64 = {
return h.id + h.result.a + h.result.b;
};
fn pickelem(sl: []handle, k: i64) handle = {
return sl[k];
};
@test fn sliceelemreturn() void = {
let hs: [4]handle = mk();
let sl: []handle = hs[0:4];
let e: handle = pickelem(sl, 2);
assert(e.id == 9);
assert(e.result.b == 31);
};
@test fn sliceelemindexedstore() void = {
let hs: [4]handle = mk();
let sl: []handle = hs[0:4];
let out: [2]inner;
let j: i64 = 0;
out[j] = sl[2].result;
assert(out[0].a == 11);
assert(out[0].b == 31);
};