authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2025-03-20 18:50:12-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-25 15:24:41+01:00
log598413357ddd06750e0830db13fbba10f72fe9c0
treef3ee46e8de2beaa87aab02ffc0a4b02056676cdd
parent0367d46d3c023122cd00f709e04b6194f977c5ef
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

Sema: use unwrapped generic owner in `getFuncInstanceIes`


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);
94449444
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;
94479447
9448 // The strategy here is to add the function decl unconditionally, then to9448 // 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 mutated9449 // 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
623test "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}