From f8ccc6dca64fe6978709064c3bf7d7f31f16ad2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 13 Feb 2026 19:29:11 +0000 Subject: [PATCH] astgen: fix while loop dbg_node, block expr rvalue, int_type data issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- astgen.c | 4 +++- astgen_test.zig | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/astgen.c b/astgen.c index 41a4d8e607..bbbca4f87e 100644 --- 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 index 8c40cc5f6f..1cd940b43f 100644 --- 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"));