// nestfield_test — nested sub-8 composite struct field at natural offsets. // Migrated from test/wcc/989_nestfield_run.c (#44/#55). For outer{a:u8, p:inner} // the natural offset of p is 1, but a pre-fix slot-padded layout put it at 8, so // construction (write) and field-access (read) disagreed and o.p.x / o.p.y read // wrong. cstage build+run was T1; the original cat-A invariant (cs==ww exit) // now rides the stronger T2 .s byte-id (test-lang-byteid). // // nested3's z proves post-composite accumulation stays natural (z follows the // 1-byte-padded inner, not the 8-byte-padded one). flat_ctl is the no-sub-8-field // control where natural and slot-padded layouts coincide. package nestfield_test; type inr = struct { x: u8, y: u8 }; type ot2 = struct { a: u8, p: inr }; type ot3 = struct { a: u8, p: inr, z: i64 }; type flt = struct { a: u8, b: i64 }; @test fn nested2() void = { let o: ot2 = ot2 { a = 5, p = inr { x = 6, y = 7 } }; assert(o.a: int == 5); assert(o.p.x: int == 6); assert(o.p.y: int == 7); }; @test fn nested3() void = { let o: ot3 = ot3 { a = 1, p = inr { x = 2, y = 3 }, z = 0x44444444i64 }; assert(o.a: int == 1); assert(o.p.x: int == 2); assert(o.p.y: int == 3); assert(o.z == 0x44444444i64); }; @test fn flat_ctl() void = { let o: flt = flt { a = 9, b = 0x33333333i64 }; assert(o.a: int == 9); assert(o.b == 0x33333333i64); };