Files
ww/test/wcc/data/r34_append_struct_call/case.ww
Hojun-Cho 50d70e74e4 w6c: append() accepts struct CALL rvalue elements (#34)
Evaluate the call pre-grow into a per-site scratch, receiving by the
N_LET matrix (sret / float / odd-tail / GP), then grow, slot, sized
ladder. Both stages, byte-identical. The two reject pins graduate to
16B GP accept rows; three new fixtures cover 24B GP, 3B/4B tails,
16B float, and 40B sret.
2026-08-08 14:10:55 +09:00

26 lines
950 B
Plaintext

//ww:run-exit 0
// #34 close: append() accepts a struct CALL rvalue element — GP
// register-class receive (24B str+i32), odd sub-8 (3B), and sized
// tail (4B) shapes, evaluated pre-grow into a per-site scratch.
package main;
type gp24 = struct { name: str, id: i32 };
type odd3 = struct { a: u8, b: u8, c: u8 };
type tail4 = struct { v: i32 };
fn mkgp(id: i32) gp24 = { let e: gp24; e.name = "x"; e.id = id; return e; };
fn mkodd() odd3 = { let e: odd3; e.a = 1u8; e.b = 2u8; e.c = 3u8; return e; };
fn mktail() tail4 = { let e: tail4; e.v = 5; return e; };
fn main() i32 = {
let gs: []gp24 = [];
append(gs, mkgp(7));
append(gs, mkgp(9));
if (gs.len != 2 || gs[0].id != 7 || gs[1].id != 9) { return 1; };
if (gs[0].name.len != 1) { return 2; };
let os_: []odd3 = [];
append(os_, mkodd());
if (os_[0].a != 1u8 || os_[0].c != 3u8) { return 3; };
let ts: []tail4 = [];
append(ts, mktail());
if (ts[0].v != 5) { return 4; };
return 0;
};