compiler: use new defer stack for inlined functions, fix #2281
Inlined functions shouldn't care about outer scope defer statements, they can't.
This commit is contained in:
parent
cddd5e1f6d
commit
f12f871432
2 changed files with 22 additions and 0 deletions
|
@ -50,6 +50,24 @@ func TestDefer(t *testing.T) {
|
|||
func f() { a += 2 }`
|
||||
eval(t, src, big.NewInt(10))
|
||||
})
|
||||
t.Run("DeferAfterInterop", func(t *testing.T) {
|
||||
src := `package main
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
defer func() {
|
||||
}()
|
||||
storage.GetContext()
|
||||
}`
|
||||
vm := vmAndCompile(t, src)
|
||||
err := vm.Run()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, vm.Estack().Len(), "stack contains unexpected items")
|
||||
})
|
||||
|
||||
t.Run("MultipleDefers", func(t *testing.T) {
|
||||
src := `package main
|
||||
var a int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue