diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-02 14:42:05 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:47:59 -0700 |
| commit | 6a15fc87ad62ec0509017c960f6983ce1493c31d (patch) | |
| tree | 4f343a0c509f7d86b533ef31b19a303b9632136d /src | |
| parent | ad54f47b95a2295e0c199decb5ff10c572317a22 (diff) | |
| download | zig-6a15fc87ad62ec0509017c960f6983ce1493c31d.tar.gz zig-6a15fc87ad62ec0509017c960f6983ce1493c31d.zip | |
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 (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 81befbf49e..ca4e761cdc 100644 --- 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, + } }; + } + }, } } |
