commit 39b2e51a2880a8306f4462be6e45dbf7b669798d (tree)
parent 0028645557ac78626873dd0f183667ff56d63a98
Author: Motiejus <motiejus@jakstys.lt>
Date: Sat, 7 Mar 2026 07:39:33 +0000
sema: fix resolveFuncRetType for single-instruction type refs
Use resolveZirTypeRef instead of returning void for instruction refs
in the single-instruction return type body case. This handles ptr_type,
int_type, array_type, etc. Matches upstream's resolveType call in zirFunc.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/stage0/sema.c b/stage0/sema.c
@@ -5388,13 +5388,18 @@ static TypeIndex resolveFuncRetType(Sema* sema, const FuncZirInfo* info) {
return IP_INDEX_VOID_TYPE;
if (info->ret_ty_body_len == 1) {
ZirInstRef ret_ty_ref = sema->code.extra[info->ret_ty_ref_pos];
- if (ret_ty_ref < ZIR_REF_START_INDEX)
- return ret_ty_ref;
- // Generic return type (e.g. param_comptime ref) — can't resolve
- // statically. Return void; caller handles cross-module fallback.
+ // Use resolveZirTypeRef which handles both pre-interned refs
+ // (<ZIR_REF_START_INDEX) and single-instruction type bodies
+ // (e.g. ptr_type, int_type, array_type, etc.).
+ // Ported from src/Sema.zig zirFunc: resolveType(block, src,
+ // ret_ty_ref).
+ InternPoolIndex resolved = resolveZirTypeRef(
+ sema, &sema->code, ret_ty_ref, UINT32_MAX, sema->file_idx);
+ if (resolved != IP_INDEX_NONE)
+ return resolved;
return IP_INDEX_VOID_TYPE;
}
- // Multi-instruction return type body — not yet supported for inline.
+ // Multi-instruction return type body: caller handles via analyzeBodyInner.
return IP_INDEX_VOID_TYPE;
}