commit 6a15fc87ad62ec0509017c960f6983ce1493c31d (tree)
parent ad54f47b95a2295e0c199decb5ff10c572317a22
Author: Jacob Young <jacobly0@users.noreply.github.com>
Date: Fri, 2 Jun 2023 14:42:05 -0400
Sema: handle generic types when coercing functions in memory
This used to be handled by `Type.eql`, but that is now a single comparison.
Diffstat:
| M | src/Sema.zig | | | 48 | ++++++++++++++++++++++++++++-------------------- |
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/Sema.zig b/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,
+ } };
+ }
+ },
}
}