compiler: fix global constant traversal

There can be no global variables, but some global constants.
Introduced in 0b44a430.
This commit is contained in:
Evgenii Stratonikov 2020-12-08 15:24:01 +03:00
parent b807fd9e7f
commit ec58bec803
3 changed files with 37 additions and 14 deletions

View file

@ -202,12 +202,22 @@ func TestExportedVariable(t *testing.T) {
}
func TestExportedConst(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/multi"
func Main() int {
return multi.SomeConst
}`
eval(t, src, big.NewInt(42))
t.Run("with vars", func(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/multi"
func Main() int {
return multi.SomeConst
}`
eval(t, src, big.NewInt(42))
})
t.Run("const only", func(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/constonly"
func Main() int {
return constonly.Answer
}`
eval(t, src, big.NewInt(42))
})
}
func TestMultipleFuncSameName(t *testing.T) {