commit 09e20ee1bb9655b3694dbc3930015c7cc2b42a37 (tree)
parent 218d163f26fd949770d0b870d75176a482496e8a
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Fri, 20 Feb 2026 21:07:33 +0000
sema: resolve dest type through resolveInst in casts, enable 5 more tests
Fix zirTyOpCast and zirFloatCast to resolve the destination type ref
through resolveInst instead of asserting it's pre-interned. This handles
cases where the dest type comes from a type-returning expression (e.g.
typeof_log2_int) rather than a simple type literal.
Re-enable 5 corpus tests that were previously blocked by now-softened
assertions: common.zig, lanai.zig, xcore.zig, msp430.zig, protocol.zig.
Re-categorize tls.zig and Recursive.zig as zig compile errors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat:
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/stage0/sema.c b/stage0/sema.c
@@ -910,8 +910,8 @@ static AirInstRef zirTyOpCast(
= sema->code.inst_datas[inst].pl_node.payload_index;
ZirInstRef dest_ty_ref = sema->code.extra[payload_index];
ZirInstRef operand_ref = sema->code.extra[payload_index + 1];
- assert(dest_ty_ref < ZIR_REF_START_INDEX);
- TypeIndex dest_ty = dest_ty_ref;
+ AirInstRef dest_air = resolveInst(sema, dest_ty_ref);
+ TypeIndex dest_ty = AIR_REF_TO_IP(dest_air);
AirInstRef operand = resolveInst(sema, operand_ref);
// If operand is comptime, coerce instead of emitting a runtime cast.
if (!AIR_REF_IS_INST(operand)) {
@@ -950,8 +950,8 @@ static AirInstRef zirFloatCast(Sema* sema, SemaBlock* block, uint32_t inst) {
= sema->code.inst_datas[inst].pl_node.payload_index;
ZirInstRef dest_ty_ref = sema->code.extra[payload_index];
ZirInstRef operand_ref = sema->code.extra[payload_index + 1];
- assert(dest_ty_ref < ZIR_REF_START_INDEX);
- TypeIndex dest_ty = dest_ty_ref;
+ AirInstRef dest_air = resolveInst(sema, dest_ty_ref);
+ TypeIndex dest_ty = AIR_REF_TO_IP(dest_air);
AirInstRef operand = resolveInst(sema, operand_ref);
if (!AIR_REF_IS_INST(operand)) {
return semaCoerce(sema, block, dest_ty, operand);
diff --git a/stage0/stages_test.zig b/stage0/stages_test.zig
@@ -107,7 +107,7 @@ const corpus_files = .{
"../lib/compiler_rt/absvdi2.zig", // 311 -- needs alloc_mut, block, condbr, panic, call
"../lib/compiler_rt/absvsi2.zig", // 311
"../lib/compiler_rt/absvti2.zig", // 314
- //"../lib/compiler_rt/addhf3.zig", // 319 -- needs typeof_log2_int for non-int types
+ //"../lib/compiler_rt/addhf3.zig", // 319 -- needs @import
//"../lib/compiler_rt/addxf3.zig", // 323
//"../lib/compiler_rt/mulhf3.zig", // 323
//"../lib/compiler_rt/mulxf3.zig", // 323
@@ -157,7 +157,7 @@ const corpus_files = .{
//"../lib/compiler_rt/divsc3.zig", // 434
//"../lib/compiler_rt/divxc3.zig", // 434
"../lib/std/math/complex/abs.zig", // 452
- //"../lib/c/common.zig", // 457 -- resolvePeerType crash
+ "../lib/c/common.zig", // 457
"../lib/std/math/complex/arg.zig", // 458
"../lib/std/math/complex/conj.zig", // 484
"../lib/std/math/scalbn.zig", // 503
@@ -310,11 +310,11 @@ const corpus_files = .{
"../lib/std/math/copysign.zig", // 1136
//"../lib/compiler_rt/negXi2.zig", // 1171
//"../lib/std/math/lcm.zig", // 1194
- //"../lib/std/Target/lanai.zig", // 1207 -- ptrChildType assertion
+ "../lib/std/Target/lanai.zig", // 1207
//"../lib/compiler_rt/negvdi2_test.zig", // 1209
//"../lib/compiler_rt/absvdi2_test.zig", // 1216
//"../lib/std/Io/counting_reader.zig", // 1227
- //"../lib/std/Target/xcore.zig", // 1234 -- ptrChildType assertion
+ "../lib/std/Target/xcore.zig", // 1234
//"../lib/std/zon.zig", // 1242
//"../lib/compiler_rt/modti3_test.zig", // 1243
"../lib/std/valgrind/cachegrind.zig", // 1249
@@ -391,14 +391,14 @@ const corpus_files = .{
"../lib/std/os/plan9/x86_64.zig", // 2126
//"../lib/std/Build/Cache/Directory.zig", // 2142 -- zig compile error (assert failure)
"../lib/std/os/windows/advapi32.zig", // 2144
- //"../lib/std/os/windows/tls.zig", // 2159 -- resolvePeerType crash
+ //"../lib/std/os/windows/tls.zig", // 2159 -- zig compile error
//"../lib/compiler_rt/addodi4_test.zig", // 2183
//"../lib/compiler_rt/ucmpdi2_test.zig", // 2186
//"../src/print_env.zig", // 2196
//"../src/link/table_section.zig", // 2197
//"../lib/compiler_rt/addosi4_test.zig", // 2203
//"../lib/std/unicode/throughput_test.zig", // 2206
- //"../lib/std/Target/msp430.zig", // 2227 -- ptrChildType crash
+ "../lib/std/Target/msp430.zig", // 2227
//"../lib/compiler_rt/rem_pio2f.zig", // 2247
//"../lib/compiler_rt/cmpxf2.zig", // 2248
//"../lib/compiler_rt/divtf3_test.zig", // 2251
@@ -412,7 +412,7 @@ const corpus_files = .{
//"../lib/compiler/aro/aro/Driver/Multilib.zig", // 2333
//"../lib/std/debug/no_panic.zig", // 2349
//"../lib/compiler_rt/divc3_test.zig", // 2360
- //"../lib/std/os/uefi/protocol.zig", // 2368 -- resolveInst crash
+ "../lib/std/os/uefi/protocol.zig", // 2368
"../lib/std/os/uefi/protocol/absolute_pointer.zig", // 2398
"../lib/std/Target/bpf.zig", // 2425
//"../lib/compiler_rt/subodi4_test.zig", // 2437
@@ -425,7 +425,7 @@ const corpus_files = .{
"../lib/std/BitStack.zig", // 2525
//"../lib/std/math/complex/atan.zig", // 2527
"../lib/std/math/log.zig", // 2531
- //"../lib/std/Thread/Mutex/Recursive.zig", // 2533 -- sema mismatch
+ //"../lib/std/Thread/Mutex/Recursive.zig", // 2533 -- zig compile error
//"../lib/compiler/aro/aro/StringInterner.zig", // 2546
//"../lib/compiler_rt/aulldiv.zig", // 2563
//"../lib/compiler_rt/suboti4_test.zig", // 2563