| author | |
| committer | |
| log | 598413357ddd06750e0830db13fbba10f72fe9c0 |
| tree | f3ee46e8de2beaa87aab02ffc0a4b02056676cdd |
| parent | 0367d46d3c023122cd00f709e04b6194f977c5ef |
| signature |
2 files changed, 13 insertions(+), 1 deletions(-)
src/InternPool.zig+1-1| ... | @@ -9443,7 +9443,7 @@ pub fn getFuncInstanceIes( | ... | @@ -9443,7 +9443,7 @@ pub fn getFuncInstanceIes( |
| 9443 | try items.ensureUnusedCapacity(4); | 9443 | try items.ensureUnusedCapacity(4); |
| 9444 | 9444 | ||
| 9445 | const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner); | 9445 | const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner); |
| 9446 | const generic_owner_ty = ip.indexToKey(ip.funcDeclInfo(arg.generic_owner).ty).func_type; | 9446 | const generic_owner_ty = ip.indexToKey(ip.funcDeclInfo(generic_owner).ty).func_type; |
| 9447 | 9447 | ||
| 9448 | // The strategy here is to add the function decl unconditionally, then to | 9448 | // The strategy here is to add the function decl unconditionally, then to |
| 9449 | // ask if it already exists, and if so, revert the lengths of the mutated | 9449 | // 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,3 +619,15 @@ test "generic parameter resolves to comptime-only type but is not marked comptim |
| 619 | const ct_result = comptime S.foo(u8, false, S.bar); | 619 | const ct_result = comptime S.foo(u8, false, S.bar); |
| 620 | comptime std.debug.assert(ct_result == 123); | 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 | } |