diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index e5c8b7e32..7f1b33eeb 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -287,23 +287,24 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { switch t := spec.(type) { case *ast.ValueSpec: for _, id := range t.Names { + c.scope.newLocal(id.Name) c.registerDebugVariable(id.Name, t.Type) } if len(t.Values) != 0 { for i, val := range t.Values { ast.Walk(c, val) - l := c.scope.newLocal(t.Names[i].Name) + l := c.scope.loadLocal(t.Names[i].Name) c.emitStoreLocal(l) } } else if c.isCompoundArrayType(t.Type) { emit.Opcode(c.prog.BinWriter, opcode.PUSH0) emit.Opcode(c.prog.BinWriter, opcode.NEWARRAY) - l := c.scope.newLocal(t.Names[0].Name) + l := c.scope.loadLocal(t.Names[0].Name) c.emitStoreLocal(l) } else if n, ok := c.isStructType(t.Type); ok { emit.Int(c.prog.BinWriter, int64(n)) emit.Opcode(c.prog.BinWriter, opcode.NEWSTRUCT) - l := c.scope.newLocal(t.Names[0].Name) + l := c.scope.loadLocal(t.Names[0].Name) c.emitStoreLocal(l) } }