// #251: narrow int/rune array-literal elements to a // declared [N]T element type at the let / def / struct-field init sites. // Migrated from test/wcc/951_arrlit_elem_narrow_run.c (accept rows; cs==ww // byte-id rides T2). The out-of-range and str-elem reject rows stay as runww // //ww:error carriers under test/wcc/data/. // // Pre-#251 cstage REJECTED in-range bare-int/rune lits at local let/def/struct // ("[4]i32 not assignable to [4]u8"); wwstage SILENTLY over-accepted out-of- // range/str at def + struct-field (a rule-7 miscompile). Element WIDTH is // declared-type-driven at cgen, so the byte-id gate confirms the emitted bytes // are u8-wide regardless of the literal node type. package arrlit_elem_narrow_test; type enc = struct { m: [4]u8 }; def D_int: [4]u8 = [65, 66, 67, 68]; def D_rune: [4]u8 = ['A', 'B', 'C', 'D']; let E: enc = enc { m = [65, 66, 67, 68] }; @test fn let_int() void = { let a: [4]u8 = [65, 66, 67, 68]; assert(a[0]: i32 == 65); }; @test fn let_rune() void = { let a: [4]u8 = ['A', 'B', 'C', 'D']; assert(a[0]: i32 == 65); }; @test fn def_int() void = { assert(D_int[0]: i32 == 65); }; @test fn def_rune() void = { assert(D_rune[0]: i32 == 65); }; @test fn struct_int() void = { assert(E.m[0]: i32 == 65); }; @test fn struct_rune() void = { let e: enc = enc { m = ['A', 'B', 'C', 'D'] }; assert(e.m[1]: i32 == 66); };