zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f8ccc6dca64fe6978709064c3bf7d7f31f16ad2d (tree)
parent 353959d28f343ea7ba47828bc521c46bd0d01b7b
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Fri, 13 Feb 2026 19:29:11 +0000

astgen: fix while loop dbg_node, block expr rvalue, int_type data issue

- whileExpr: emit emitDbgNode before condition evaluation to match
  upstream AstGen.zig:6579. Fixes astgen_test.zig corpus (1 missing
  DBG_STMT).
- Block expressions in exprRl: wrap blockExprExpr result with rvalue()
  to handle result location storage (RL_PTR → STORE_NODE, etc.).
  Fixes parser_test.zig inst_len to exact match.
- parser_test.zig corpus now has matching inst_len and all tags, but
  has 1 int_type data signedness mismatch (pre-existing issue).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Mastgen.c | 4+++-
Mastgen_test.zig | 4++--
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/astgen.c b/astgen.c @@ -4374,7 +4374,7 @@ static uint32_t exprRl(GenZir* gz, Scope* scope, ResultLoc rl, uint32_t node) { case AST_NODE_BLOCK_TWO_SEMICOLON: case AST_NODE_BLOCK: case AST_NODE_BLOCK_SEMICOLON: - return blockExprExpr(gz, scope, rl, node); + return rvalue(gz, rl, blockExprExpr(gz, scope, rl, node), node); // Anonymous array init (AstGen.zig:1119-1127). case AST_NODE_ARRAY_INIT_DOT_TWO: case AST_NODE_ARRAY_INIT_DOT_TWO_COMMA: @@ -5611,6 +5611,8 @@ static uint32_t whileExpr( // Evaluate condition in cond_scope (AstGen.zig:6571-6607). GenZir cond_scope = makeSubBlock(&loop_scope, &loop_scope.base); + // Emit debug node for the condition expression (AstGen.zig:6579). + emitDbgNode(&cond_scope, cond_node); uint32_t cond = expr(&cond_scope, &cond_scope.base, cond_node); // Create condbr + cond_block (AstGen.zig:6609-6615). diff --git a/astgen_test.zig b/astgen_test.zig @@ -798,8 +798,8 @@ test "astgen: corpus tokenizer_test.zig" { } test "astgen: corpus parser_test.zig" { - // TODO: 1 inst diff — 1 STORE_NODE inside ptr-based struct init with - // block field init expression. + // TODO: int_type signedness data mismatch at inst[6899] — all tags and + // inst_len match, but one int_type has ref=signed got=unsigned. if (true) return error.SkipZigTest; const gpa = std.testing.allocator; try corpusCheck(gpa, @embedFile("parser_test.zig"));