astgen.c: call identAsString before underscore check in whileExpr to match upstream string table ordering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 14:29:14 +00:00
parent 5760399448
commit 4077250e26
2 changed files with 7 additions and 3 deletions

View File

@@ -10160,13 +10160,15 @@ static uint32_t whileExpr(
payload_ref = raw_idx + ZIR_REF_START_INDEX;
opt_payload_raw_inst = raw_idx;
payload_ident_token = payload_token + (payload_is_ref ? 1u : 0u);
// identAsString must be called before the underscore check to
// match upstream AstGen.zig:6669 which inserts the string first.
payload_ident_name = identAsString(ag, payload_ident_token);
if (tokenIsUnderscore(tree, payload_ident_token)) {
if (payload_is_ref) {
SET_ERROR(ag);
return ZIR_REF_VOID_VALUE;
}
} else {
payload_ident_name = identAsString(ag, payload_ident_token);
payload_has_scope = true;
}
}
@@ -10279,10 +10281,12 @@ static uint32_t whileExpr(
: ZIR_INST_ERR_UNION_CODE;
uint32_t err_inst
= addUnNode(&else_scope, err_tag, cond_inst, cond_node);
// identAsString must be called before the underscore check to
// match upstream AstGen.zig:6762 which inserts the string first.
uint32_t err_name = identAsString(ag, error_token);
if (tokenIsUnderscore(tree, error_token)) {
// Discard |_| — else_sub_scope stays as &else_scope.base
} else {
uint32_t err_name = identAsString(ag, error_token);
error_val_scope = (ScopeLocalVal) {
.base = { .tag = SCOPE_LOCAL_VAL },
.parent = &else_scope.base,

View File

@@ -1299,7 +1299,7 @@ const corpus_files = .{
"../test/behavior/type_info.zig",
"../test/behavior/typename.zig",
"../test/behavior/undefined.zig",
//"../test/behavior/underscore.zig",
"../test/behavior/underscore.zig",
"../test/behavior/union_with_members.zig",
//"../test/behavior/var_args.zig",
"../test/behavior/void.zig",