commit 7d6be1e23d8a65e8d6e8b8745024a4641e71523e (tree)
parent a31ff38fd9e37194ba46f1c74aa2a9b761da4f13
Author: Motiejus <motiejus@jakstys.lt>
Date: Sun, 1 Mar 2026 14:33:22 +0000
sema: handle enum_literal signedness in @Type(.int) reification
When @Type(.{.int = .{.signedness = .unsigned, .bits = N}}) is used,
the signedness value may be an enum_literal (.unsigned/.signed)
rather than a comptime integer. Decode the literal name to get the
correct signedness value.
Also add forward declaration for floatTypeBits used by @typeInfo
float case.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/stage0/sema.c b/stage0/sema.c
@@ -9767,6 +9767,14 @@ static AirInstRef zirReifyComptime(Sema* sema, uint32_t inst) {
InternPoolKey k = sema->ip->items[AIR_REF_TO_IP(fv)];
if (k.tag == IP_KEY_INT)
signedness = (uint32_t)k.data.int_val.value_lo;
+ else if (k.tag == IP_KEY_ENUM_LITERAL) {
+ // .unsigned = 0, .signed = 1
+ uint32_t str_idx = k.data.enum_literal;
+ const char* lit = (const char*)&sema->ip
+ ->string_bytes[str_idx];
+ if (strcmp(lit, "signed") == 0)
+ signedness = 1;
+ }
} else if (strcmp(fn, "bits") == 0 && AIR_REF_IS_IP(fv)) {
InternPoolKey k = sema->ip->items[AIR_REF_TO_IP(fv)];
if (k.tag == IP_KEY_INT)