astgen: fix assignStmt discard to propagate RL_DISCARD to expr

Pass RL_DISCARD directly to exprRl in the _ = expr discard path,
instead of evaluating with RL_NONE and then calling rvalueDiscard.
This matches upstream AstGen.zig:3444 behavior where expression
handlers see the discard RL and can optimize accordingly (e.g.
arrayInitExpr evaluates elements individually with discard RL
instead of emitting array_init_anon).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 20:04:03 +00:00
parent 99af7d4623
commit 143702e9d9

View File

@@ -10367,9 +10367,11 @@ static void assignStmt(GenZir* gz, Scope* scope, uint32_t infix_node) {
|| tree->source[tok_start + 1] == '_'
|| (tree->source[tok_start + 1] >= '0'
&& tree->source[tok_start + 1] <= '9')))) {
// Discard: evaluate RHS with .discard result location.
uint32_t result = expr(gz, scope, rhs);
rvalueDiscard(gz, result, rhs);
// Discard: evaluate RHS with .discard result location
// (AstGen.zig:3444).
ResultLoc discard_rl = RL_DISCARD_VAL;
discard_rl.ctx = RI_CTX_ASSIGNMENT;
(void)exprRl(gz, scope, discard_rl, rhs);
return;
}
}