From b8d749cc3796400e0aff95f1fd67e047dcdad71b Mon Sep 17 00:00:00 2001 From: Motiejus Date: Sun, 1 Mar 2026 16:13:38 +0000 Subject: [PATCH] stage0: handle decl_val in param type body, bump num_passing to 5 The parameter type resolution had a gap: 2-instruction type bodies were only handled for ptr_type, missing decl_val+break_inline (used when a parameter type references a module-level const like `const U32 = @Type(...)`). Add a general fallback using analyzeBodyInner for non-ptr_type 2-instruction bodies. This enables reify_int.zig which uses @Type to create u32. Co-Authored-By: Claude Opus 4.6 (1M context) --- stage0/corpus.zig | 2 +- stage0/sema.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/stage0/corpus.zig b/stage0/corpus.zig index 767f00a0d5..99f0340e81 100644 --- a/stage0/corpus.zig +++ b/stage0/corpus.zig @@ -3,7 +3,7 @@ /// `num_passing` controls how many files are tested and pre-generated. /// Both build.zig and stages_test.zig import this file. /// To enable more tests: just increment `num_passing`. -pub const num_passing: usize = 4; +pub const num_passing: usize = 5; pub const files = [_][]const u8{ "stage0/sema_tests/empty.zig", diff --git a/stage0/sema.c b/stage0/sema.c index 12abee47fa..a6344b6fb5 100644 --- a/stage0/sema.c +++ b/stage0/sema.c @@ -8156,6 +8156,23 @@ static void analyzeFuncBodyAndRecord(Sema* sema, SemaBlock* block, key.data.ptr_type.child = elem_ty; key.data.ptr_type.flags = ip_flags; param_ty = ipIntern(sema->ip, key); + } else { + // General case: analyze the type body in comptime + // context (e.g. decl_val + break_inline for + // references to module-level type aliases). + const uint32_t* type_body + = &sema->code.extra[param_payload + 2]; + instMapEnsureSpaceForBody( + &sema->inst_map, type_body, type_body_len_p); + fn_block.is_comptime = true; + (void)analyzeBodyInner( + sema, &fn_block, type_body, type_body_len_p); + fn_block.is_comptime = false; + ZirInstRef type_operand + = sema->code.inst_datas[sema->comptime_break_inst] + .break_data.operand; + AirInstRef type_air = resolveInst(sema, type_operand); + param_ty = AIR_REF_TO_IP(type_air); } } else if (type_body_len_p > 2) { const uint32_t* type_body