fix: remove misleading error note for failed array coercions

This commit is contained in:
WillLillis 2024-07-20 02:31:19 -04:00 committed by Andrew Kelley
parent 9b292c0949
commit 18d412ab2f
2 changed files with 22 additions and 7 deletions

View File

@ -30279,7 +30279,7 @@ pub fn coerceInMemoryAllowed(
if ((src_info.signedness == dest_info.signedness and dest_info.bits < src_info.bits) or
// small enough unsigned ints can get casted to large enough signed ints
(dest_info.signedness == .signed and (src_info.signedness == .unsigned or dest_info.bits <= src_info.bits)) or
(dest_info.signedness == .signed and src_info.signedness == .unsigned and dest_info.bits <= src_info.bits) or
(dest_info.signedness == .unsigned and src_info.signedness == .signed))
{
return InMemoryCoercionResult{ .int_not_coercible = .{
@ -30360,12 +30360,16 @@ pub fn coerceInMemoryAllowed(
}
const child = try sema.coerceInMemoryAllowed(block, dest_info.elem_type, src_info.elem_type, dest_is_mut, target, dest_src, src_src, null);
if (child != .ok) {
return InMemoryCoercionResult{ .array_elem = .{
.child = try child.dupe(sema.arena),
.actual = src_info.elem_type,
.wanted = dest_info.elem_type,
} };
switch (child) {
.ok => {},
.no_match => return child,
else => {
return InMemoryCoercionResult{ .array_elem = .{
.child = try child.dupe(sema.arena),
.actual = src_info.elem_type,
.wanted = dest_info.elem_type,
} };
},
}
const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
(src_info.sentinel != null and

View File

@ -0,0 +1,11 @@
export fn a() void {
const x = [_]u16{ 1, 2, 3 };
const y: [3]i32 = x;
_ = y;
}
// error
// backend=stage2
// target=native
//
// 3:23: error: expected type '[3]i32', found '[3]u16'