diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-01-12 20:55:30 +0000 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-01-13 02:57:15 +0000 |
| commit | f78f9388fe79f084d5ea028e6270a410eacfc316 (patch) | |
| tree | 40b3eeb986f9fdc8866a9d41134b41801a5adc84 /src | |
| parent | 15fe99957226aa27da838812ec891f11b299453d (diff) | |
| download | zig-f78f9388fe79f084d5ea028e6270a410eacfc316.tar.gz zig-f78f9388fe79f084d5ea028e6270a410eacfc316.zip | |
Sema: allow tail calls of function pointers
Resolves: #22474
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 6b5aba0a23..c0c02bae58 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -7983,7 +7983,13 @@ fn analyzeCall( } if (call_tag == .call_always_tail) { - return sema.handleTailCall(block, call_src, sema.typeOf(runtime_func), result); + const func_or_ptr_ty = sema.typeOf(runtime_func); + const runtime_func_ty = switch (func_or_ptr_ty.zigTypeTag(zcu)) { + .@"fn" => func_or_ptr_ty, + .pointer => func_or_ptr_ty.childType(zcu), + else => unreachable, + }; + return sema.handleTailCall(block, call_src, runtime_func_ty, result); } if (resolved_ret_ty.toIntern() == .noreturn_type) { |
