diff --git a/compiler/gengo/emit_stmt.go b/compiler/gengo/emit_stmt.go index 009d829..8252805 100644 --- a/compiler/gengo/emit_stmt.go +++ b/compiler/gengo/emit_stmt.go @@ -461,11 +461,12 @@ func (g *Generator) emitAssign(a *ast.AssignExpr, locals localMap) { g.emitExpr(a.Right) g.emitBinaryOp(a.Op) // Stack now: [folded value]. Re-push X/index to set. - g.writeln("_v := t.Pop2()") + // Scope _v so multiple compound assigns in the same function don't redeclare. + g.writeln("{ _v := t.Pop2()") g.emitExpr(idx.X) g.emitExpr(idx.Index) g.writeln("t.PushValue(_v)") - g.writeln("t.ArrayPop()") + g.writeln("t.ArrayPop() }") return }