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(...@@ -30670,6 +30670,7 @@ fn coerceTupleToArray(
30670 const inst_ty = sema.typeOf(inst);30670 const inst_ty = sema.typeOf(inst);
30671 const inst_len = inst_ty.arrayLen(zcu);30671 const inst_len = inst_ty.arrayLen(zcu);
30672 const dest_len = dest_ty.arrayLen(zcu);30672 const dest_len = dest_ty.arrayLen(zcu);
30673 const dest_len_including_sent = dest_ty.arrayLenIncludingSentinel(zcu);
3067330674
30674 if (dest_len != inst_len) {30675 if (dest_len != inst_len) {
30675 const msg = msg: {30676 const msg = msg: {
...@@ -30682,7 +30683,7 @@ fn coerceTupleToArray(...@@ -30682,7 +30683,7 @@ fn coerceTupleToArray(
30682 return sema.failWithOwnedErrorMsg(block, msg);30683 return sema.failWithOwnedErrorMsg(block, msg);
30683 }30684 }
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);
30686 const element_vals = try sema.arena.alloc(InternPool.Index, dest_elems);30687 const element_vals = try sema.arena.alloc(InternPool.Index, dest_elems);
30687 const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_elems);30688 const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_elems);
30688 const dest_elem_ty = dest_ty.childType(zcu);30689 const dest_elem_ty = dest_ty.childType(zcu);
test/behavior/array.zig+3
...@@ -591,6 +591,9 @@ test "tuple to array handles sentinel" {...@@ -591,6 +591,9 @@ test "tuple to array handles sentinel" {
591 var b: [3:0]u8 = a;591 var b: [3:0]u8 = a;
592 };592 };
593 try expect(S.b[0] == 1);593 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);
594}597}
595598
596test "array init of container level array variable" {599test "array init of container level array variable" {