mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
compiler: use fully-qualified names for tracking functions
Function name now consists of 3 parts: 1) full package path 2) method receiver type (if any) 3) function name itself . Fix #1150. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
528c184f00
commit
a781d299e0
8 changed files with 87 additions and 15 deletions
|
@ -196,3 +196,33 @@ func TestExportedConst(t *testing.T) {
|
|||
}`
|
||||
eval(t, src, big.NewInt(42))
|
||||
}
|
||||
|
||||
func TestMultipleFuncSameName(t *testing.T) {
|
||||
t.Run("Simple", func(t *testing.T) {
|
||||
src := `package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/multi"
|
||||
func Main() int {
|
||||
return multi.Sum() + Sum()
|
||||
}
|
||||
func Sum() int {
|
||||
return 11
|
||||
}`
|
||||
eval(t, src, big.NewInt(53))
|
||||
})
|
||||
t.Run("WithMethod", func(t *testing.T) {
|
||||
src := `package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/foo"
|
||||
type Foo struct{}
|
||||
func (f Foo) Bar() int { return 11 }
|
||||
func Bar() int { return 22 }
|
||||
func Main() int {
|
||||
var a Foo
|
||||
var b foo.Foo
|
||||
return a.Bar() + // 11
|
||||
foo.Bar() + // 1
|
||||
b.Bar() + // 8
|
||||
Bar() // 22
|
||||
}`
|
||||
eval(t, src, big.NewInt(42))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue