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>
This commit is contained in:
2026-03-07 07:39:33 +00:00
parent 0028645557
commit 39b2e51a28

View File

@@ -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;
}