| author | |
| committer | |
| log | 89db4f2e9390a75b73be3d20a95df78e376cfdd5 |
| tree | b3d321a4f95efaaa808c6c9e676e2f8b0c4328e2 |
| parent | 972cab5bb027dce3d4f700e381bec3e1724c9504 |
2 files changed, 13 insertions(+), 1 deletions(-)
src/InternPool.zig+1-1| ... | ... | @@ -9455,7 +9455,7 @@ pub fn getFuncInstanceIes( |
| 9455 | 9455 | try items.ensureUnusedCapacity(4); |
| 9456 | 9456 | |
| 9457 | 9457 | const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner); |
| 9458 | const generic_owner_ty = ip.indexToKey(ip.funcDeclInfo(arg.generic_owner).ty).func_type; | |
| 9458 | const generic_owner_ty = ip.indexToKey(ip.funcDeclInfo(generic_owner).ty).func_type; | |
| 9459 | 9459 | |
| 9460 | 9460 | // The strategy here is to add the function decl unconditionally, then to |
| 9461 | 9461 | // ask if it already exists, and if so, revert the lengths of the mutated |
test/behavior/generics.zig+12| ... | ... | @@ -619,3 +619,15 @@ test "generic parameter resolves to comptime-only type but is not marked comptim |
| 619 | 619 | const ct_result = comptime S.foo(u8, false, S.bar); |
| 620 | 620 | comptime std.debug.assert(ct_result == 123); |
| 621 | 621 | } |
| 622 | ||
| 623 | test "instantiate coerced generic function" { | |
| 624 | const S = struct { | |
| 625 | fn generic(comptime T: type, arg: *const u8) !void { | |
| 626 | _ = T; | |
| 627 | _ = arg; | |
| 628 | } | |
| 629 | }; | |
| 630 | const coerced: fn (comptime type, *u8) anyerror!void = S.generic; | |
| 631 | var x: u8 = 20; | |
| 632 | try coerced(u8, &x); | |
| 633 | } |