mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Sema: fix generic function instance with comptime return type
This commit is contained in:
parent
722bd22508
commit
1b70fca534
1 changed files with 12 additions and 0 deletions
12
src/Sema.zig
12
src/Sema.zig
|
|
@ -7552,6 +7552,18 @@ fn instantiateGenericCall(
|
|||
// Make a runtime call to the new function, making sure to omit the comptime args.
|
||||
const func_ty = callee.ty.toType();
|
||||
const func_ty_info = mod.typeToFunc(func_ty).?;
|
||||
|
||||
// If the call evaluated to a return type that requires comptime, never mind
|
||||
// our generic instantiation. Instead we need to perform a comptime call.
|
||||
if (try sema.typeRequiresComptime(func_ty_info.return_type.toType())) {
|
||||
return error.ComptimeReturn;
|
||||
}
|
||||
// Similarly, if the call evaluated to a generic type we need to instead
|
||||
// call it inline.
|
||||
if (func_ty_info.is_generic or func_ty_info.cc == .Inline) {
|
||||
return error.GenericPoison;
|
||||
}
|
||||
|
||||
const runtime_args_len: u32 = func_ty_info.param_types.len;
|
||||
const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue