compiler: initialize packages according to go spec

`init()` functions should be called during package initialization,
after global variables were processed.
This commit is contained in:
Evgenii Stratonikov 2020-08-05 11:14:43 +03:00
parent 6f2759be3a
commit 439d9ff94d
4 changed files with 37 additions and 5 deletions

View file

@ -80,4 +80,11 @@ func TestImportOrder(t *testing.T) {
func Main() int { return pkg3.A }`
eval(t, src, big.NewInt(1))
})
t.Run("InitializeOnce", func(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/pkg3"
var A = pkg3.A
func Main() int { return A }`
eval(t, src, big.NewInt(3))
})
}