commit af9f80f2f7c4828b65fe075975fcd95982b1a7e3 (tree)
parent 8cdc8667f407c24d96452c66c3afe94d10ae1a5d
Author: Motiejus <motiejus@jakstys.lt>
Date: Sat, 7 Mar 2026 09:57:04 +0000
sema: add validate-only no-op handlers for array/error union ZIR insts
Add no-op instMapPut handlers (mapped to IP_INDEX_VOID_VALUE) for
validation-only instructions that produce no meaningful value:
- ZIR_INST_VALIDATE_ARRAY_INIT_TY/RESULT_TY/REF_TY
- ZIR_INST_VALIDATE_DESTRUCTURE
- ZIR_INST_VALIDATE_PTR_ARRAY_INIT
- ZIR_INST_ENSURE_RESULT_NON_ERROR
- ZIR_INST_ENSURE_ERR_UNION_PAYLOAD_VOID
These were previously falling through to the default case (void mapping)
and are now explicitly handled as no-ops.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/stage0/sema.c b/stage0/sema.c
@@ -12686,6 +12686,20 @@ bool analyzeBodyInner(
i++;
continue;
+ // Validation-only instructions: no value produced, no AIR emitted.
+ // These validate preconditions but don't produce useful values.
+ case ZIR_INST_VALIDATE_ARRAY_INIT_TY:
+ case ZIR_INST_VALIDATE_ARRAY_INIT_RESULT_TY:
+ case ZIR_INST_VALIDATE_ARRAY_INIT_REF_TY:
+ case ZIR_INST_VALIDATE_DESTRUCTURE:
+ case ZIR_INST_VALIDATE_PTR_ARRAY_INIT:
+ case ZIR_INST_ENSURE_RESULT_NON_ERROR:
+ case ZIR_INST_ENSURE_ERR_UNION_PAYLOAD_VOID:
+ instMapPut(
+ &sema->inst_map, inst, AIR_REF_FROM_IP(IP_INDEX_VOID_VALUE));
+ i++;
+ continue;
+
// For all other instructions, produce a void mapping and skip.
// As handlers are implemented, they will replace this default.
default: {