From 0e855d5c5ecc6d5727b2fa4d80ce31008a69bf2f Mon Sep 17 00:00:00 2001 From: Motiejus Date: Sat, 7 Mar 2026 09:33:58 +0000 Subject: [PATCH] =?UTF-8?q?sema:=20add=20comptime=5Fint=20=E2=86=92=20bool?= =?UTF-8?q?=20coercion=20in=20semaCoerce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When coercing comptime_int to bool, produce the correct bool constant (IP_INDEX_BOOL_TRUE/FALSE) instead of trying to create an IP_KEY_INT entry with bool type (which wouldn't match the pre-interned bool constants). Ported from Sema.zig coerce comptime_int → bool path. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- stage0/sema.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stage0/sema.c b/stage0/sema.c index a78e22ac67..d136583383 100644 --- a/stage0/sema.c +++ b/stage0/sema.c @@ -726,6 +726,16 @@ static AirInstRef semaCoerce( if (src_ty == TYPE_NONE || target_ty == TYPE_NONE) return ref; if (src_ty == IP_INDEX_COMPTIME_INT_TYPE) { + // comptime_int → bool: 0 → false, 1 → true. + // Ported from Sema.zig coerce comptime_int → bool path. + if (target_ty == IP_INDEX_BOOL_TYPE && AIR_REF_IS_IP(ref)) { + InternPoolKey src_key = ipIndexToKey(sema->ip, AIR_REF_TO_IP(ref)); + if (src_key.tag == IP_KEY_INT) { + return AIR_REF_FROM_IP(src_key.data.int_val.value_lo != 0 + ? IP_INDEX_BOOL_TRUE + : IP_INDEX_BOOL_FALSE); + } + } // comptime_int → float type: convert int to float value. // Ported from Sema.zig coerce comptime_int → float path. if ((floatBits(target_ty) > 0