diff --git a/src/Sema.zig b/src/Sema.zig index 11f250e44c206e0570ab744bf35b937f5053e51c..517b04bc4bb3436b890fe0837f019f33ffc8dab5 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -16033,7 +16033,6 @@ fn coerce( }, .Pointer => p: { const inst_info = inst_ty.ptrInfo().data; - if (inst_info.size == .Slice) break :p; switch (try sema.coerceInMemoryAllowed( block, dest_info.pointee_type, @@ -16046,6 +16045,14 @@ fn coerce( .ok => {}, .no_match => break :p, } + if (inst_info.size == .Slice) { + if (dest_info.sentinel == null or inst_info.sentinel == null or + !dest_info.sentinel.?.eql(inst_info.sentinel.?, dest_info.pointee_type)) + break :p; + + const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); + return sema.coerceCompatiblePtrs(block, dest_ty, slice_ptr, inst_src); + } return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); }, else => {}, @@ -16089,7 +16096,30 @@ fn coerce( return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src); } }, - .Many => {}, + .Many => p: { + const inst_info = inst_ty.ptrInfo().data; + if (inst_info.size != .Slice) break :p; + + switch (try sema.coerceInMemoryAllowed( + block, + dest_info.pointee_type, + inst_info.pointee_type, + dest_info.mutable, + target, + dest_ty_src, + inst_src, + )) { + .ok => {}, + .no_match => break :p, + } + + if (dest_info.sentinel == null or inst_info.sentinel == null or + !dest_info.sentinel.?.eql(inst_info.sentinel.?, dest_info.pointee_type)) + break :p; + + const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); + return sema.coerceCompatiblePtrs(block, dest_ty, slice_ptr, inst_src); + }, } // This will give an extra hint on top of what the bottom of this func would provide.