commit eba04d91cc1848a138c966ebf9431ff9d250aea8 (tree)
parent 7d52ad5e974d1b0b841eb957295173a24122eed1
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Mon, 16 Feb 2026 22:47:52 +0000
astgen.c: fix forExpr to use nodeIsTriviallyZero for range start check
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat:
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/stage0/astgen.c b/stage0/astgen.c
@@ -9924,17 +9924,8 @@ static uint32_t forExpr(
lens[i][1] = end_val;
}
- // Check if start is trivially zero.
- bool start_is_zero = false;
- if (tree->nodes.tags[start_node] == AST_NODE_NUMBER_LITERAL) {
- uint32_t tok = tree->nodes.main_tokens[start_node];
- uint32_t ts = tree->tokens.starts[tok];
- if (tree->source[ts] == '0'
- && (ts + 1 >= tree->source_len
- || tree->source[ts + 1] < '0'
- || tree->source[ts + 1] > '9'))
- start_is_zero = true;
- }
+ // Check if start is trivially zero (AstGen.zig:6915).
+ bool start_is_zero = nodeIsTriviallyZero(tree, start_node);
indexables[i] = start_is_zero ? ZIR_REF_NONE : start_val;
} else {
// Regular indexable (AstGen.zig:6918-6923).
diff --git a/stage0/stages_test.zig b/stage0/stages_test.zig
@@ -37,7 +37,7 @@ const corpus_files = .{
"../lib/compiler/aro/aro/Builtins/TypeDescription.zig",
"../lib/compiler/aro/aro/Builtins.zig",
"../lib/compiler/aro/aro/char_info/identifier_tables.zig",
- //"../lib/compiler/aro/aro/char_info.zig",
+ "../lib/compiler/aro/aro/char_info.zig",
"../lib/compiler/aro/aro/CodeGen.zig",
"../lib/compiler/aro/aro/Compilation.zig",
"../lib/compiler/aro/aro/Diagnostics/messages.zig",