mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
compiler: consider inlined types info on "append" handling
We need to search for "append" argument type info not only inside local package type info map, but also inside the inlined type info map. Close #2696.
This commit is contained in:
parent
3dbd36ef70
commit
5d578fdd95
3 changed files with 17 additions and 1 deletions
|
@ -1819,7 +1819,7 @@ func (c *codegen) convertBuiltin(expr *ast.CallExpr) {
|
|||
emit.Opcodes(c.prog.BinWriter, opcode.DROP, opcode.PUSH0)
|
||||
case "append":
|
||||
arg := expr.Args[0]
|
||||
typ := c.typeInfo.Types[arg].Type
|
||||
typ := c.typeOf(arg)
|
||||
ast.Walk(c, arg)
|
||||
emit.Opcodes(c.prog.BinWriter, opcode.DUP, opcode.ISNULL)
|
||||
if isByteSlice(typ) {
|
||||
|
|
|
@ -432,3 +432,14 @@ func TestInlineDoubleConditionalReturn(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInlineAppendStatement(t *testing.T) {
|
||||
src := `package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline"
|
||||
|
||||
func Main() []byte {
|
||||
val := []byte{4, 5, 6}
|
||||
return inline.AppendInsideInline(val)
|
||||
}`
|
||||
eval(t, src, []byte{1, 2, 3, 4, 5, 6})
|
||||
}
|
||||
|
|
5
pkg/compiler/testdata/inline/inline.go
vendored
5
pkg/compiler/testdata/inline/inline.go
vendored
|
@ -64,3 +64,8 @@ func NewT() T {
|
|||
func (t T) GetN() int {
|
||||
return t.N
|
||||
}
|
||||
|
||||
func AppendInsideInline(val []byte) []byte {
|
||||
inlinedType := []byte{1, 2, 3}
|
||||
return append(inlinedType, val...)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue