astgen: fix double ZIR_REF_START_INDEX in assignOp

addInstruction() already returns idx + ZIR_REF_START_INDEX (a ref),
so the extra + ZIR_REF_START_INDEX on the inplace_arith_result_ty path
resulted in a double-offset (+248 instead of +124) being stored in
extra data for += and -= compound assignments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 17:00:29 +00:00
parent c3d4777536
commit 6910aeb897
2 changed files with 2 additions and 3 deletions

View File

@@ -5963,8 +5963,7 @@ static void assignOp(
ext_data.extended.opcode = (uint16_t)ZIR_EXT_INPLACE_ARITH_RESULT_TY;
ext_data.extended.small = inplace_op;
ext_data.extended.operand = lhs;
rhs_res_ty = addInstruction(gz, ZIR_INST_EXTENDED, ext_data)
+ ZIR_REF_START_INDEX;
rhs_res_ty = addInstruction(gz, ZIR_INST_EXTENDED, ext_data);
} else {
rhs_res_ty = addUnNode(gz, ZIR_INST_TYPEOF, lhs, infix_node);
}

View File

@@ -798,7 +798,7 @@ test "astgen: corpus tokenizer_test.zig" {
}
test "astgen: corpus astgen_test.zig" {
if (true) return error.SkipZigTest; // TODO: store_node ref off-by-1 at inst 1764
if (true) return error.SkipZigTest; // TODO: extra data offset mismatches
const gpa = std.testing.allocator;
try corpusCheck(gpa, @embedFile("astgen_test.zig"));
}