| ... | @@ -21793,7 +21793,7 @@ fn coerceTupleToArray( | ... | @@ -21793,7 +21793,7 @@ fn coerceTupleToArray( |
| 21793 | ) !Air.Inst.Ref { | 21793 | ) !Air.Inst.Ref { |
| 21794 | const inst_ty = sema.typeOf(inst); | 21794 | const inst_ty = sema.typeOf(inst); |
| 21795 | const inst_len = inst_ty.arrayLen(); | 21795 | const inst_len = inst_ty.arrayLen(); |
| 21796 | const dest_len = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLen()); | 21796 | const dest_len = dest_ty.arrayLen(); |
| 21797 | | 21797 | |
| 21798 | if (dest_len != inst_len) { | 21798 | if (dest_len != inst_len) { |
| 21799 | const msg = msg: { | 21799 | const msg = msg: { |
| ... | @@ -21808,13 +21808,19 @@ fn coerceTupleToArray( | ... | @@ -21808,13 +21808,19 @@ fn coerceTupleToArray( |
| 21808 | return sema.failWithOwnedErrorMsg(block, msg); | 21808 | return sema.failWithOwnedErrorMsg(block, msg); |
| 21809 | } | 21809 | } |
| 21810 | | 21810 | |
| 21811 | const element_vals = try sema.arena.alloc(Value, dest_len); | 21811 | const dest_elems = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLenIncludingSentinel()); |
| 21812 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_len); | 21812 | const element_vals = try sema.arena.alloc(Value, dest_elems); |
| | 21813 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_elems); |
| 21813 | const dest_elem_ty = dest_ty.childType(); | 21814 | const dest_elem_ty = dest_ty.childType(); |
| 21814 | | 21815 | |
| 21815 | var runtime_src: ?LazySrcLoc = null; | 21816 | var runtime_src: ?LazySrcLoc = null; |
| 21816 | for (element_vals) |*elem, i_usize| { | 21817 | for (element_vals) |*elem, i_usize| { |
| 21817 | const i = @intCast(u32, i_usize); | 21818 | const i = @intCast(u32, i_usize); |
| | 21819 | if (i_usize == inst_len) { |
| | 21820 | elem.* = dest_ty.sentinel().?; |
| | 21821 | element_refs[i] = try sema.addConstant(dest_elem_ty, elem.*); |
| | 21822 | break; |
| | 21823 | } |
| 21818 | const elem_src = inst_src; // TODO better source location | 21824 | const elem_src = inst_src; // TODO better source location |
| 21819 | const elem_ref = try tupleField(sema, block, inst_src, inst, elem_src, i); | 21825 | const elem_ref = try tupleField(sema, block, inst_src, inst, elem_src, i); |
| 21820 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); | 21826 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); |