| ... | @@ -18166,6 +18166,19 @@ fn coerce( | ... | @@ -18166,6 +18166,19 @@ fn coerce( |
| 18166 | { | 18166 | { |
| 18167 | return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src); | 18167 | return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src); |
| 18168 | } | 18168 | } |
| | 18169 | |
| | 18170 | // empty tuple to zero-length slice |
| | 18171 | // note that this allows coercing to a mutable slice. |
| | 18172 | if (inst_ty.isSinglePointer() and |
| | 18173 | inst_ty.childType().tag() == .empty_struct_literal and |
| | 18174 | dest_info.size == .Slice) |
| | 18175 | { |
| | 18176 | const slice_val = try Value.Tag.slice.create(sema.arena, .{ |
| | 18177 | .ptr = Value.undef, |
| | 18178 | .len = Value.zero, |
| | 18179 | }); |
| | 18180 | return sema.addConstant(dest_ty, slice_val); |
| | 18181 | } |
| 18169 | }, | 18182 | }, |
| 18170 | .Many => p: { | 18183 | .Many => p: { |
| 18171 | if (!inst_ty.isSlice()) break :p; | 18184 | if (!inst_ty.isSlice()) break :p; |