authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-10-20 01:27:43-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-10-20 11:56:52-07:00
log30b1ec85dd5d11a7dd767275ae3e65f17035d2f3
tree223551d1dd1852bf19f8b189bc7e06dbc0065ecc
parent0b737050465cfd9a9a497ffed60517d52fd2e0db

Sema: include sentinel in dest elems when coercing tuple to array


2 files changed, 5 insertions(+), 1 deletions(-)

src/Sema.zig+2-1
......@@ -30670,6 +30670,7 @@ fn coerceTupleToArray(
3067030670 const inst_ty = sema.typeOf(inst);
3067130671 const inst_len = inst_ty.arrayLen(zcu);
3067230672 const dest_len = dest_ty.arrayLen(zcu);
30673 const dest_len_including_sent = dest_ty.arrayLenIncludingSentinel(zcu);
3067330674
3067430675 if (dest_len != inst_len) {
3067530676 const msg = msg: {
......@@ -30682,7 +30683,7 @@ fn coerceTupleToArray(
3068230683 return sema.failWithOwnedErrorMsg(block, msg);
3068330684 }
3068430685
30685 const dest_elems = try sema.usizeCast(block, dest_ty_src, dest_len);
30686 const dest_elems = try sema.usizeCast(block, dest_ty_src, dest_len_including_sent);
3068630687 const element_vals = try sema.arena.alloc(InternPool.Index, dest_elems);
3068730688 const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_elems);
3068830689 const dest_elem_ty = dest_ty.childType(zcu);
test/behavior/array.zig+3
......@@ -591,6 +591,9 @@ test "tuple to array handles sentinel" {
591591 var b: [3:0]u8 = a;
592592 };
593593 try expect(S.b[0] == 1);
594 try expect(S.b[1] == 2);
595 try expect(S.b[2] == 3);
596 try expect(S.b[3] == 0);
594597}
595598
596599test "array init of container level array variable" {