From 39b2e51a2880a8306f4462be6e45dbf7b669798d Mon Sep 17 00:00:00 2001 From: Motiejus Date: Sat, 7 Mar 2026 07:39:33 +0000 Subject: [PATCH] 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) --- stage0/sema.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stage0/sema.c b/stage0/sema.c index 530f322f47..93a8402df9 100644 --- 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 + // (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; }