mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Sema: handle generic types when coercing functions in memory
This used to be handled by `Type.eql`, but that is now a single comparison.
This commit is contained in:
parent
ad54f47b95
commit
6a15fc87ad
48
src/Sema.zig
48
src/Sema.zig
@ -27498,17 +27498,20 @@ fn coerceInMemoryAllowedFns(
|
||||
} };
|
||||
}
|
||||
|
||||
if (src_info.return_type != .noreturn_type) {
|
||||
const dest_return_type = dest_info.return_type.toType();
|
||||
const src_return_type = src_info.return_type.toType();
|
||||
const rt = try sema.coerceInMemoryAllowed(block, dest_return_type, src_return_type, false, target, dest_src, src_src);
|
||||
if (rt != .ok) {
|
||||
return InMemoryCoercionResult{ .fn_return_type = .{
|
||||
.child = try rt.dupe(sema.arena),
|
||||
.actual = dest_return_type,
|
||||
.wanted = src_return_type,
|
||||
} };
|
||||
}
|
||||
switch (src_info.return_type) {
|
||||
.noreturn_type, .generic_poison_type => {},
|
||||
else => {
|
||||
const dest_return_type = dest_info.return_type.toType();
|
||||
const src_return_type = src_info.return_type.toType();
|
||||
const rt = try sema.coerceInMemoryAllowed(block, dest_return_type, src_return_type, false, target, dest_src, src_src);
|
||||
if (rt != .ok) {
|
||||
return InMemoryCoercionResult{ .fn_return_type = .{
|
||||
.child = try rt.dupe(sema.arena),
|
||||
.actual = dest_return_type,
|
||||
.wanted = src_return_type,
|
||||
} };
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -27548,15 +27551,20 @@ fn coerceInMemoryAllowedFns(
|
||||
} };
|
||||
}
|
||||
|
||||
// Note: Cast direction is reversed here.
|
||||
const param = try sema.coerceInMemoryAllowed(block, src_param_ty, dest_param_ty, false, target, dest_src, src_src);
|
||||
if (param != .ok) {
|
||||
return InMemoryCoercionResult{ .fn_param = .{
|
||||
.child = try param.dupe(sema.arena),
|
||||
.actual = src_param_ty,
|
||||
.wanted = dest_param_ty,
|
||||
.index = param_i,
|
||||
} };
|
||||
switch (src_param_ty.toIntern()) {
|
||||
.generic_poison_type => {},
|
||||
else => {
|
||||
// Note: Cast direction is reversed here.
|
||||
const param = try sema.coerceInMemoryAllowed(block, src_param_ty, dest_param_ty, false, target, dest_src, src_src);
|
||||
if (param != .ok) {
|
||||
return InMemoryCoercionResult{ .fn_param = .{
|
||||
.child = try param.dupe(sema.arena),
|
||||
.actual = src_param_ty,
|
||||
.wanted = dest_param_ty,
|
||||
.index = param_i,
|
||||
} };
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user