authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-13 21:15:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 19:02:06-07:00
log1b70fca534c64a412270897f06938c50f0b7b39c
treea84fd9f87e3aebc6c42bdc12c0841a31195aa1df
parent722bd22508a7f1f5ab05685002d30e8d7fc2b2a2

Sema: fix generic function instance with comptime return type


1 files changed, 12 insertions(+), 0 deletions(-)

src/Sema.zig+12
......@@ -7552,6 +7552,18 @@ fn instantiateGenericCall(
75527552 // Make a runtime call to the new function, making sure to omit the comptime args.
75537553 const func_ty = callee.ty.toType();
75547554 const func_ty_info = mod.typeToFunc(func_ty).?;
7555
7556 // If the call evaluated to a return type that requires comptime, never mind
7557 // our generic instantiation. Instead we need to perform a comptime call.
7558 if (try sema.typeRequiresComptime(func_ty_info.return_type.toType())) {
7559 return error.ComptimeReturn;
7560 }
7561 // Similarly, if the call evaluated to a generic type we need to instead
7562 // call it inline.
7563 if (func_ty_info.is_generic or func_ty_info.cc == .Inline) {
7564 return error.GenericPoison;
7565 }
7566
75557567 const runtime_args_len: u32 = func_ty_info.param_types.len;
75567568 const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);
75577569 {