// structlit_arrfield_test — struct array-field init + read (global let/def and // local lit). Migrated from test/wcc/949_structlit_arrfield_run.c (#249). BUG B: // reading a [4]u8 field of a module-global struct SEGFAULTed on wwstage; BUG A: // a local struct-lit array field fell to the scalar tail and dropped every // element but the first. Fix = cg_structlit_fill array arm + def_isstructdef // LOAD widening (ADDQ $field_off). cstage build+run was T1; cs==ww .s byte-id // rides T2 (test-lang-byteid). The def row has a [3]u8 pad ahead of encmap, so // the read exercises a non-zero field offset (the base64 std_encoding shape). package structlit_arrfield_test; type e1 = struct { encmap: [4]u8 }; let GE: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] }; type e2 = struct { pad: [3]u8, encmap: [4]u8 }; def GD: e2 = e2 { pad = [9u8, 9u8, 9u8], encmap = [65u8, 66u8, 67u8, 68u8] }; @test fn global_let_read() void = { assert(GE.encmap[0]: i32 == 65); }; @test fn global_def_read_off() void = { assert(GD.encmap[2]: i32 == 67); }; @test fn local_lit_read0() void = { let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] }; assert(g.encmap[0]: i32 == 65); }; @test fn local_lit_read3() void = { let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] }; assert(g.encmap[3]: i32 == 68); };