sema: replace TODO silent fallbacks with UNIMPLEMENTED

- zirBuiltinValue: unhandled builtin_value kinds now crash with
  UNIMPLEMENTED instead of silently returning VOID_VALUE
- zirModRem: detect signed integer types and fail with
  UNIMPLEMENTED instead of silently treating as @rem

Convention: never use "TODO ... return VOID_VALUE". Handle known
cases explicitly, UNIMPLEMENTED for the rest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 07:03:40 +00:00
parent 8151f6dc9b
commit a8bdfd6507

View File

@@ -2471,9 +2471,18 @@ static AirInstRef zirRem(Sema* sema, SemaBlock* block, uint32_t inst) {
// zirModRem: handle plain '%' operator (may be mod or rem depending on types).
// Ported from src/Sema.zig zirModRem.
static AirInstRef zirModRem(Sema* sema, SemaBlock* block, uint32_t inst) {
// Ported from Sema.zig zirModRem: for unsigned types, same as @rem.
// Signed types would need distinct handling (mod vs rem ambiguity).
// TODO: check signedness and UNIMPLEMENTED for signed types.
// Ported from Sema.zig zirModRem: for unsigned integers, '%' is
// equivalent to @rem. For signed integers, '%' is @mod which
// needs distinct handling (not yet ported).
uint32_t payload_index = sema->code.inst_datas[inst].pl_node.payload_index;
AirInstRef lhs = resolveInst(sema, sema->code.extra[payload_index]);
TypeIndex lhs_ty = semaTypeOf(sema, lhs);
if (lhs_ty != IP_INDEX_COMPTIME_INT_TYPE
&& sema->ip->items[lhs_ty].tag == IP_KEY_INT_TYPE) {
InternPoolKey k = ipIndexToKey(sema->ip, lhs_ty);
if (k.data.int_type.signedness == 1)
UNIMPLEMENTED("zirModRem: signed integer mod");
}
return zirRem(sema, block, inst);
}
@@ -11324,8 +11333,8 @@ static AirInstRef zirExtended(Sema* sema, SemaBlock* block, uint32_t inst) {
}
}
}
// TODO: implement remaining builtin_value kinds
return AIR_REF_FROM_IP(IP_INDEX_VOID_VALUE);
UNIMPLEMENTED("zirBuiltinValue: unimplemented builtin_value kind");
return AIR_REF_FROM_IP(IP_INDEX_VOID_VALUE); // unreachable
}
UNIMPLEMENTED("zirExtended: unimplemented extended opcode");
return AIR_REF_FROM_IP(IP_INDEX_VOID_VALUE); // unreachable