diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 793181b94..cdb7a0ab5 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -432,8 +432,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { if !isAssignOp { ast.Walk(c, n.Rhs[i]) } - name := t.X.(*ast.Ident).Name - c.emitLoadVar(name) + ast.Walk(c, t.X) ast.Walk(c, t.Index) emit.Opcode(c.prog.BinWriter, opcode.ROT) emit.Opcode(c.prog.BinWriter, opcode.SETITEM) diff --git a/pkg/compiler/slice_test.go b/pkg/compiler/slice_test.go index af7d07f80..326fe0e72 100644 --- a/pkg/compiler/slice_test.go +++ b/pkg/compiler/slice_test.go @@ -212,6 +212,16 @@ var sliceTestCases = []testCase{ }`, []byte{1, 2}, }, + { + "nested slice assignment", + `package foo + func Main() int { + a := [][]int{[]int{1, 2}, []int{3, 4}} + a[1][0] = 42 + return a[1][0] + }`, + big.NewInt(42), + }, } func TestSliceOperations(t *testing.T) {