Repository: goplus/gop
Pull request #1690 (2024-01-30 08:04:41)

TestGopxNoFunc


Patch:
diff --git a/cl/compile.go b/cl/compile.go
index 50761274..d38cf780 100644
--- a/cl/compile.go
+++ b/cl/compile.go
@@ -630,9 +630,6 @@ func isOverloadFunc(name string) bool {
 	return n > 3 && name[n-3:n-1] == "__"
 }
 
-//go:linkname initThisGopPkg github.com/goplus/gox.initThisGopPkg
-func initThisGopPkg(pkg *types.Package)
-
 func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
 	for name, f := range ctx.syms {
 		if gopSyms[name] {
@@ -654,7 +651,7 @@ func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
 	if pkg.Types.Scope().Lookup(gopPackage) == nil {
 		pkg.Types.Scope().Insert(types.NewConst(token.NoPos, pkg.Types, gopPackage, types.Typ[types.UntypedBool], constant.MakeBool(true)))
 	}
-	initThisGopPkg(pkg.Types)
+	gox.InitThisGopPkg(pkg.Types)
 }
 
 func getEntrypoint(f *ast.File) string {
@@ -832,6 +829,10 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
 			}
 			parent.tylds = append(parent.tylds, ld)
 		}
+
+		// bugfix: see TestGopxNoFunc
+		parent.lbinames = append(parent.lbinames, classType)
+
 		ctx.classRecv = &ast.FieldList{List: []*ast.Field{{
 			Names: []*ast.Ident{
 				{Name: "this"},
diff --git a/cl/expr.go b/cl/expr.go
index fb6cc143..c712e9d9 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -99,7 +99,7 @@ func compileIdent(ctx *blockCtx, ident *ast.Ident, flags int) (pkg gox.PkgRef, k
 			sig := fn.Ancestor().Type().(*types.Signature)
 			if recv := sig.Recv(); recv != nil {
 				ctx.cb.Val(recv)
-				chkFlag := flags &^ clCommandWithoutArgs
+				chkFlag := flags // &^ clCommandWithoutArgs (TODO: why?)
 				if chkFlag&clIdentSelectorExpr != 0 {
 					chkFlag = clIdentCanAutoCall
 				}
diff --git a/cl/internal/spx/game.go b/cl/internal/spx/game.go
index 9367eae7..e7b1f1c1 100644
--- a/cl/internal/spx/game.go
+++ b/cl/internal/spx/game.go
@@ -29,6 +29,9 @@ type MyGame struct {
 func Gopt_MyGame_Main(game interface{}) {
 }
 
+func (p *MyGame) InitGameApp(args ...string) {
+}
+
 func (p *MyGame) Broadcast__0(msg string) {
 }
 
diff --git a/go.mod b/go.mod
index bb02a687..cc237ce2 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.18
 require (
 	github.com/fsnotify/fsnotify v1.7.0
 	github.com/goplus/c2go v0.7.20
-	github.com/goplus/gox v1.14.1
+	github.com/goplus/gox v1.14.1-0.20240130050415-3bd8cee57731
 	github.com/goplus/mod v0.12.3
 	github.com/qiniu/x v1.13.2
 	golang.org/x/tools v0.17.0
diff --git a/go.sum b/go.sum
index f4de2102..5b2b5572 100644
--- a/go.sum
+++ b/go.sum
@@ -7,8 +7,8 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
 github.com/goplus/c2go v0.7.20 h1:90HiO7tuX8hHfEnl7HZRmLsAPH9q2wsYIvHiJMpwtU8=
 github.com/goplus/c2go v0.7.20/go.mod h1:hToieb5V4BMY3c431DQ7DEg13JQ+q9qGmls4+GgymrA=
 github.com/goplus/gox v1.14.0/go.mod h1:G7Hz+cAOUyJyN9pPHrpqhfQPDUtiJNmoRVTwoaQ9nw0=
-github.com/goplus/gox v1.14.1 h1:ppqY4xzwc6UaeProYf4pn5fMa4xSDe80PsSsBfCYZ3U=
-github.com/goplus/gox v1.14.1/go.mod h1:G7Hz+cAOUyJyN9pPHrpqhfQPDUtiJNmoRVTwoaQ9nw0=
+github.com/goplus/gox v1.14.1-0.20240130050415-3bd8cee57731 h1:ZjWvtPmuf15J8dmcl1ILOmxi400Bf1y6mAMsVPUbg7I=
+github.com/goplus/gox v1.14.1-0.20240130050415-3bd8cee57731/go.mod h1:G7Hz+cAOUyJyN9pPHrpqhfQPDUtiJNmoRVTwoaQ9nw0=
 github.com/goplus/mod v0.12.2/go.mod h1:ZtlS9wHOcAVxZ/zq7WLdKVes1HG/8Yn3KNuWZGcpeTs=
 github.com/goplus/mod v0.12.3 h1:qLU5/F27CzUTQhCQRN1WruiCepUn5GdLKQTB41OsYfk=
 github.com/goplus/mod v0.12.3/go.mod h1:ZtlS9wHOcAVxZ/zq7WLdKVes1HG/8Yn3KNuWZGcpeTs=


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index e3ff38b4..b09eaf65 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -255,6 +255,588 @@ func main() {
 `)
 }
 
+func TestOverload(t *testing.T) {
+	gopClTest(t, `
+import "github.com/goplus/gop/cl/internal/overload/foo"
+
+type Mesh struct {
+}
+
+func (p *Mesh) Name() string {
+	return "hello"
+}
+
+var (
+	m1 = &Mesh{}
+	m2 = &Mesh{}
+)
+
+foo.onKey "hello", => {
+}
+foo.onKey "hello", key => {
+}
+foo.onKey ["1"], => {
+}
+foo.onKey ["2"], key => {
+}
+foo.onKey [m1, m2], => {
+}
+foo.onKey [m1, m2], key => {
+}
+foo.onKey ["a"], ["b"], key => {
+}
+foo.onKey ["a"], [m1, m2], key => {
+}
+foo.onKey ["a"], nil, key => {
+}
+foo.onKey 100, 200
+
+n := &foo.N{}
+n.onKey "hello", => {
+}
+n.onKey "hello", key => {
+}
+n.onKey ["1"], => {
+}
+n.onKey ["2"], key => {
+}
+n.onKey [m1, m2], => {
+}
+n.onKey [m1, m2], key => {
+}
+n.onKey ["a"], ["b"], key => {
+}
+n.onKey ["a"], [m1, m2], key => {
+}
+n.onKey ["a"], nil, key => {
+}
+n.onKey 100, 200
+`, `package main
+
+import "github.com/goplus/gop/cl/internal/overload/foo"
+
+type Mesh struct {
+}
+
+func (p *Mesh) Name() string {
+	return "hello"
+}
+
+var m1 = &Mesh{}
+var m2 = &Mesh{}
+
+func main() {
+	foo.OnKey__0("hello", func() {
+	})
+	foo.OnKey__1("hello", func(key string) {
+	})
+	foo.OnKey__2([]string{"1"}, func() {
+	})
+	foo.OnKey__3([]string{"2"}, func(key string) {
+	})
+	foo.OnKey__4([]foo.Mesher{m1, m2}, func() {
+	})
+	foo.OnKey__5([]foo.Mesher{m1, m2}, func(key foo.Mesher) {
+	})
+	foo.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
+	})
+	foo.OnKey__7([]string{"a"}, []foo.Mesher{m1, m2}, func(key string) {
+	})
+	foo.OnKey__6([]string{"a"}, nil, func(key string) {
+	})
+	foo.OnKey__8(100, 200)
+	n := &foo.N{}
+	n.OnKey__0("hello", func() {
+	})
+	n.OnKey__1("hello", func(key string) {
+	})
+	n.OnKey__2([]string{"1"}, func() {
+	})
+	n.OnKey__3([]string{"2"}, func(key string) {
+	})
+	n.OnKey__4([]foo.Mesher{m1, m2}, func() {
+	})
+	n.OnKey__5([]foo.Mesher{m1, m2}, func(key foo.Mesher) {
+	})
+	n.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
+	})
+	n.OnKey__7([]string{"a"}, []foo.Mesher{m1, m2}, func(key string) {
+	})
+	n.OnKey__6([]string{"a"}, nil, func(key string) {
+	})
+	n.OnKey__8(100, 200)
+}
+`)
+}
+
+func TestMixedOverload(t *testing.T) {
+	gopMixedClTest(t, "main", `
+package main
+
+type Mesher interface {
+	Name() string
+}
+
+type N struct {
+}
+
+func (m *N) OnKey__0(a string, fn func()) {
+}
+
+func (m *N) OnKey__1(a string, fn func(key string)) {
+}
+
+func (m *N) OnKey__2(a []string, fn func()) {
+}
+
+func (m *N) OnKey__3(a []string, fn func(key string)) {
+}
+
+func (m *N) OnKey__4(a []Mesher, fn func()) {
+}
+
+func (m *N) OnKey__5(a []Mesher, fn func(key Mesher)) {
+}
+
+func (m *N) OnKey__6(a []string, b []string, fn func(key string)) {
+}
+
+func (m *N) OnKey__7(a []string, b []Mesher, fn func(key string)) {
+}
+
+func (m *N) OnKey__8(x int, y int) {
+}
+
+
+func OnKey__0(a string, fn func()) {
+}
+
+func OnKey__1(a string, fn func(key string)) {
+}
+
+func OnKey__2(a []string, fn func()) {
+}
+
+func OnKey__3(a []string, fn func(key string)) {
+}
+
+func OnKey__4(a []Mesher, fn func()) {
+}
+
+func OnKey__5(a []Mesher, fn func(key Mesher)) {
+}
+
+func OnKey__6(a []string, b []string, fn func(key string)) {
+}
+
+func OnKey__7(a []string, b []Mesher, fn func(key string)) {
+}
+
+func OnKey__8(x int, y int) {
+}
+
+func OnKey__9(a, b string, fn ...func(x int) int) {
+}
+
+func OnKey__a(a, b string, v ...int) {
+}
+`, `
+type Mesh struct {
+}
+
+func (p *Mesh) Name() string {
+	return "hello"
+}
+
+var (
+	m1 = &Mesh{}
+	m2 = &Mesh{}
+)
+
+OnKey "hello", => {
+}
+OnKey "hello", key => {
+}
+OnKey ["1"], => {
+}
+OnKey ["2"], key => {
+}
+OnKey [m1, m2], => {
+}
+OnKey [m1, m2], key => {
+}
+OnKey ["a"], ["b"], key => {
+}
+OnKey ["a"], [m1, m2], key => {
+}
+OnKey ["a"], nil, key => {
+}
+OnKey 100, 200
+OnKey "a", "b", x => x * x, x => {
+	return x * 2
+}
+OnKey "a", "b", 1, 2, 3
+OnKey("a", "b", [1, 2, 3]...)
+
+n := &N{}
+n.onKey "hello", => {
+}
+n.onKey "hello", key => {
+}
+n.onKey ["1"], => {
+}
+n.onKey ["2"], key => {
+}
+n.onKey [m1, m2], => {
+}
+n.onKey [m1, m2], key => {
+}
+n.onKey ["a"], ["b"], key => {
+}
+n.onKey ["a"], [m1, m2], key => {
+}
+n.onKey ["a"], nil, key => {
+}
+n.onKey 100, 200
+`, `package main
+
+type Mesh struct {
+}
+
+func (p *Mesh) Name() string {
+	return "hello"
+}
+
+var m1 = &Mesh{}
+var m2 = &Mesh{}
+
+func main() {
+	OnKey__0("hello", func() {
+	})
+	OnKey__1("hello", func(key string) {
+	})
+	OnKey__2([]string{"1"}, func() {
+	})
+	OnKey__3([]string{"2"}, func(key string) {
+	})
+	OnKey__4([]Mesher{m1, m2}, func() {
+	})
+	OnKey__5([]Mesher{m1, m2}, func(key Mesher) {
+	})
+	OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
+	})
+	OnKey__7([]string{"a"}, []Mesher{m1, m2}, func(key string) {
+	})
+	OnKey__6([]string{"a"}, nil, func(key string) {
+	})
+	OnKey__8(100, 200)
+	OnKey__9("a", "b", func(x int) int {
+		return x * x
+	}, func(x int) int {
+		return x * 2
+	})
+	OnKey__a("a", "b", 1, 2, 3)
+	OnKey__a("a", "b", []int{1, 2, 3}...)
+	n := &N{}
+	n.OnKey__0("hello", func() {
+	})
+	n.OnKey__1("hello", func(key string) {
+	})
+	n.OnKey__2([]string{"1"}, func() {
+	})
+	n.OnKey__3([]string{"2"}, func(key string) {
+	})
+	n.OnKey__4([]Mesher{m1, m2}, func() {
+	})
+	n.OnKey__5([]Mesher{m1, m2}, func(key Mesher) {
+	})
+	n.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
+	})
+	n.OnKey__7([]string{"a"}, []Mesher{m1, m2}, func(key string) {
+	})
+	n.OnKey__6([]string{"a"}, nil, func(key string) {
+	})
+	n.OnKey__8(100, 200)
+}
+`)
+}
+
+func TestMixedOverloadOp(t *testing.T) {
+	gopMixedClTest(t, "main", `package main
+
+import "fmt"
+
+type foo struct {
+}
+
+func (a *foo) Gop_Add(b *foo) *foo {
+	fmt.Println("a + b")
+	return &foo{}
+}
+func (a foo) Gop_Sub(b foo) foo {
+	fmt.Println("a - b")
+	return foo{}
+}
+func (a foo) Gop_NE(b foo) bool {
+	fmt.Println("a!=b")
+	return true
+}
+func (a foo) Gop_Neg() *foo {
+	fmt.Println("-a")
+	return &foo{}
+}
+func (a foo) Gop_Inc() {
+	fmt.Println("a++")
+}
+`, `
+var a, b foo
+var c = a - b
+var d = -a
+var e = a!=b
+`, `package main
+
+var a, b foo
+var c = (foo).Gop_Sub(a, b)
+var d = a.Gop_Neg()
+var e = (foo).Gop_NE(a, b)
+`)
+}
+
+func TestMixedVector3(t *testing.T) {
+	gopMixedClTest(t, "main", `package main
+type Vector3 struct {
+	x, y, z float64
+}
+func (a Vector3) Gop_Add__0(n int) Vector3 {
+	return Vector3{}
+}
+func (a Vector3) Gop_Add__1(n float64) Vector3 {
+	return Vector3{}
+}
+func (a Vector3) Gop_Add__2(n Vector3) Vector3 {
+	return Vector3{}
+}
+func (a *Vector3) Gop_AddAssign(n Vector3) {
+}
+
+func (a Vector3) Gop_Rcast__0() int {
+	return 0
+}
+func (a Vector3) Gop_Rcast__1() float64 {
+	return 0
+}
+
+func Vector3_Cast__0(x int) Vector3 {
+	return Vector3{}
+}
+func Vector3_Cast__1(x float64) Vector3 {
+	return Vector3{}
+}
+func Vector3_Init__0(x int) Vector3 {
+	return Vector3{}
+}
+func Vector3_Init__1(x float64) Vector3 {
+	return Vector3{}
+}
+`, `
+var a Vector3
+var b int
+var c float64
+_ = a+b
+_ = a+100
+_ = a+c
+_ = 100+a
+_ = Vector3(b)+a
+_ = b+int(a)
+a += b
+a += c
+`, `package main
+
+var a Vector3
+var b int
+var c float64
+
+func main() {
+	_ = (Vector3).Gop_Add__0(a, b)
+	_ = (Vector3).Gop_Add__0(a, 100)
+	_ = (Vector3).Gop_Add__1(a, c)
+	_ = (Vector3).Gop_Add__2(Vector3_Init__0(100), a)
+	_ = (Vector3).Gop_Add__2(Vector3_Cast__0(b), a)
+	_ = b + a.Gop_Rcast__0()
+	a.Gop_AddAssign(Vector3_Init__0(b))
+	a.Gop_AddAssign(Vector3_Init__1(c))
+}
+`)
+}
+
+func TestMixedInterfaceOverload(t *testing.T) {
+	gopMixedClTest(t, "main", `
+package main
+
+type N[T any] struct {
+	v T
+}
+
+func (m *N[T]) OnKey__0(a string, fn func()) {
+}
+
+func (m *N[T]) OnKey__1(a string, fn func(key string)) {
+}
+
+func (m *N[T]) OnKey__2(a []string, fn func()) {
+}
+
+func (m *N[T]) OnKey__3(a []string, fn func(key string)) {
+}
+
+type I interface {
+	OnKey__0(a string, fn func())
+	OnKey__1(a string, fn func(key string))
+	OnKey__2(a []string, fn func())
+	OnKey__3(a []string, fn func(key string))
+}
+`, `
+n := &N[int]{}
+n.onKey "1", => {
+}
+keys := ["1","2"]
+n.onKey keys, key => {
+	println key
+}
+n.onKey keys, => {
+	println keys
+}
+
+var i I = n
+i.onKey "1", key => {
+	println key
+}
+i.onKey ["1","2"], key => {
+	println key
+}
+`, `package main
+
+import "fmt"
+
+func main() {
+	n := &N[int]{}
+	n.OnKey__0("1", func() {
+	})
+	keys := []string{"1", "2"}
+	n.OnKey__3(keys, func(key string) {
+		fmt.Println(key)
+	})
+	n.OnKey__2(keys, func() {
+		fmt.Println(keys)
+	})
+	var i I = n
+	i.OnKey__1("1", func(key string) {
+		fmt.Println(key)
+	})
+	i.OnKey__3([]string{"1", "2"}, func(key string) {
+		fmt.Println(key)
+	})
+}
+`)
+}
+
+func TestMixedOverloadCommand(t *testing.T) {
+	gopMixedClTest(t, "main", `package main
+
+func Test__0() {
+}
+func Test__1(n int) {
+}
+type N struct {
+}
+func (p *N) Test__0() {
+}
+func (p *N) Test__1(n int) {
+}`, `
+Test
+Test 100
+var n N
+n.test
+n.test 100
+`, `package main
+
+func main() {
+	Test__0()
+	Test__1(100)
+	var n N
+	n.Test__0()
+	n.Test__1(100)
+}
+`)
+}
+
+func TestOverloadNamed(t *testing.T) {
+	gopClTest(t, `
+import "github.com/goplus/gop/cl/internal/overload/bar"
+
+var a bar.Var[int]
+var b bar.Var[bar.M]
+c := bar.Var(string)
+d := bar.Var(bar.M)
+`, `package main
+
+import "github.com/goplus/gop/cl/internal/overload/bar"
+
+var a bar.Var__0[int]
+var b bar.Var__1[map[string]any]
+
+func main() {
+	c := bar.Gopx_Var_Cast__0[string]()
+	d := bar.Gopx_Var_Cast__1[map[string]any]()
+}
+`)
+}
+
+func TestMixedOverloadNamed(t *testing.T) {
+	gopMixedClTest(t, "main", `package main
+
+const GopPackage = true
+
+type M = map[string]any
+
+type basetype interface {
+	string | int | bool | float64
+}
+
+type Var__0[T basetype] struct {
+	val T
+}
+
+type Var__1[T map[string]any] struct {
+	val T
+}
+
+func Gopx_Var_Cast__0[T basetype]() *Var__0[T] {
+	return new(Var__0[T])
+}
+
+func Gopx_Var_Cast__1[T map[string]any]() *Var__1[T] {
+	return new(Var__1[T])
+}
+`, `
+var a Var[int]
+var b Var[M]
+c := Var(string)
+d := Var(M)
+`, `package main
+
+var a Var__0[int]
+var b Var__1[map[string]interface {
+}]
+
+func main() {
+	c := Gopx_Var_Cast__0[string]()
+	d := Gopx_Var_Cast__1[map[string]interface {
+	}]()
+}
+`)
+}
+
 func TestStringLitBasic(t *testing.T) {
 	gopClTest(t, `echo "$$"`, `package main
 
diff --git a/cl/compile_spx_test.go b/cl/compile_spx_test.go
index 03f289e4..7d0dbef7 100644
--- a/cl/compile_spx_test.go
+++ b/cl/compile_spx_test.go
@@ -168,6 +168,8 @@ func onInit() {
 	for {
 	}
 }
+
+initGameApp
 `, `
 func onMsg(msg string) {
 	for {
@@ -181,18 +183,22 @@ import "github.com/goplus/gop/cl/internal/spx"
 type Game struct {
 	*spx.MyGame
 }
+type Kai struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) onInit() {
 	for {
 		spx.SchedNow()
 	}
 }
-
-type Kai struct {
-	spx.Sprite
-	*Game
+func (this *Game) MainEntry() {
+	this.InitGameApp()
+}
+func main() {
+	spx.Gopt_MyGame_Main(new(Game))
 }
-
 func (this *Kai) onMsg(msg string) {
 	for {
 		spx.Sched()
@@ -229,6 +235,10 @@ import (
 
 const Foo = 1
 
+type bar struct {
+	spx.Sprite
+	*index
+}
 type index struct {
 	*spx.MyGame
 }
@@ -267,6 +277,10 @@ import (
 type Game struct {
 	*spx.MyGame
 }
+type bar struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) onInit() {
 	spx.Sched()
@@ -274,12 +288,6 @@ func (this *Game) onInit() {
 	spx.TestIntValue = 1
 	x := math.Round(1.2)
 }
-
-type bar struct {
-	spx.Sprite
-	*Game
-}
-
 func (this *bar) onInit() {
 	this.SetCostume("kai-a")
 	this.Play("recordingWhere")
@@ -315,15 +323,15 @@ func onCloned() {
 
 import "github.com/goplus/gop/cl/internal/spx"
 
+type Game struct {
+	*spx.MyGame
+	Kai Kai
+}
 type Kai struct {
 	spx.Sprite
 	*Game
 	a int
 }
-type Game struct {
-	*spx.MyGame
-	Kai Kai
-}
 
 func (this *Game) onInit() {
 	spx.Gopt_Sprite_Clone__0(this.Kai)
@@ -361,15 +369,14 @@ type Kai struct {
 	spx.Sprite
 	*index
 }
-
-var x float64 = spx.Rand__1(1.2)
-
 type index struct {
 	*spx.MyGame
 	Kai Kai
 	t   spx.Sound
 }
 
+var x float64 = spx.Rand__1(1.2)
+
 func (this *index) MainEntry() {
 	spx.Gopt_MyGame_Run(this, "hzip://open.qiniu.us/weather/res.zip")
 }
@@ -435,6 +442,10 @@ import (
 type Game struct {
 	spx2.Game
 }
+type Kai struct {
+	spx2.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	fmt.Println("Hi")
@@ -442,12 +453,6 @@ func (this *Game) MainEntry() {
 func main() {
 	new(Game).Main()
 }
-
-type Kai struct {
-	spx2.Sprite
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 }
 `, "Game.t2gmx", "Kai.t2spx")
@@ -469,6 +474,10 @@ import (
 type Game struct {
 	spx2.Game
 }
+type Kai struct {
+	spx2.Sprite2
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	fmt.Println("Hi, Sprite2")
@@ -476,12 +485,6 @@ func (this *Game) MainEntry() {
 func main() {
 	new(Game).Main()
 }
-
-type Kai struct {
-	spx2.Sprite2
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 }
 `, "Game.t2gmx", "Kai.t2spx2")
@@ -503,15 +506,13 @@ import (
 type Dog struct {
 	spx2.Sprite
 }
-
-func (this *Dog) Main() {
-	fmt.Println("Hi, Sprite")
-}
-
 type Kai struct {
 	spx2.Sprite2
 }
 
+func (this *Dog) Main() {
+	fmt.Println("Hi, Sprite")
+}
 func (this *Kai) onMsg(msg string) {
 }
 `, "Dog_t3spx.gox", "Kai.t3spx2")
@@ -531,6 +532,10 @@ import "github.com/goplus/gop/cl/internal/spx2"
 type Game struct {
 	spx2.Game
 }
+type Kai struct {
+	spx2.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 }
@@ -547,14 +552,14 @@ var (
 
 import "github.com/goplus/gop/cl/internal/spx2"
 
-type Kai struct {
-	spx2.Sprite
-	*Game
-}
 type Game struct {
 	spx2.Game
 	Kai Kai
 }
+type Kai struct {
+	spx2.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 }
@@ -583,14 +588,14 @@ import (
 	"github.com/goplus/gop/cl/internal/spx2"
 )
 
-type Kai struct {
-	spx2.Sprite
-	*Game
-}
 type Game struct {
 	spx2.Game
 	Kai Kai
 }
+type Kai struct {
+	spx2.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	fmt.Println("Hi")
@@ -625,18 +630,16 @@ import "github.com/goplus/gop/cl/internal/spx"
 type Game struct {
 	*spx.MyGame
 }
+type Kai struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) onInit() {
 	for {
 		spx.SchedNow()
 	}
 }
-
-type Kai struct {
-	spx.Sprite
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 	for {
 		spx.Sched()
@@ -684,15 +687,15 @@ type info struct {
 	x int
 	y int
 }
+type Game struct {
+	*spx.MyGame
+	Kai Kai
+}
 type Kai struct {
 	spx.Sprite
 	*Game
 	a int
 }
-type Game struct {
-	*spx.MyGame
-	Kai Kai
-}
 
 func (this *Game) onInit() {
 	spx.Gopt_Sprite_Clone__0(this.Kai)
@@ -731,6 +734,10 @@ import "github.com/goplus/gop/cl/internal/spx"
 type Game struct {
 	*spx.MyGame
 }
+type Kai struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	this.SendMessage("Hi")
@@ -738,12 +745,6 @@ func (this *Game) MainEntry() {
 func main() {
 	spx.Gopt_MyGame_Main(new(Game))
 }
-
-type Kai struct {
-	spx.Sprite
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 }
 `, "Game.tgmx", "Kai.tspx")
@@ -766,6 +767,10 @@ import (
 type Game struct {
 	*spx.MyGame
 }
+type Kai struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	fmt.Println("Hi")
@@ -773,12 +778,6 @@ func (this *Game) MainEntry() {
 func main() {
 	spx.Gopt_MyGame_Main(new(Game))
 }
-
-type Kai struct {
-	spx.Sprite
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 	this.Position().Add__0(100, 200)
 }
@@ -815,6 +814,10 @@ import (
 type Game struct {
 	*spx.MyGame
 }
+type Kai struct {
+	spx.Sprite
+	*Game
+}
 
 func (this *Game) MainEntry() {
 	fmt.Println("hi")
@@ -822,12 +825,6 @@ func (this *Game) MainEntry() {
 func main() {
 	spx.Gopt_MyGame_Main(new(Game))
 }
-
-type Kai struct {
-	spx.Sprite
-	*Game
-}
-
 func (this *Kai) onMsg(msg string) {
 	fmt.Println(msg)
 	this.Position().Add__0(100, 200)
@@ -900,15 +897,15 @@ import "github.com/goplus/gop/cl/internal/spx"
 
 type Mesh struct {
 }
+type Game struct {
+	*spx.MyGame
+	Kai Kai
+}
 type Kai struct {
 	spx.Sprite
 	*Game
 	a int
 }
-type Game struct {
-	*spx.MyGame
-	Kai Kai
-}
 
 func (this *Game) onInit() {
 	spx.Gopt_Sprite_OnKey__1(this.Kai, "hello", func(key string) {
@@ -963,6 +960,10 @@ import (
 	"testing"
 )
 
+type caseFoo struct {
+	test.Case
+	*App
+}
 type App struct {
 	test.App
 }
@@ -970,12 +971,6 @@ type App struct {
 func (this *App) MainEntry() {
 	fmt.Println("Hi")
 }
-
-type caseFoo struct {
-	test.Case
-	*App
-}
-
 func (this *caseFoo) Main() {
 	this.T().Log("Hi")
 	this.T().Run("a test", func(t *testing.T) {
@@ -1015,3 +1010,148 @@ func Test_foo(t *testing.T) {
 }
 `, "main.gox", "foo_xtest.gox", "_test")
 }
+
+func TestGopxNoFunc(t *testing.T) {
+	gopClTestFile(t, `
+var (
+	a int
+)
+`, `package main
+
+type foo struct {
+	a int
+}
+`, "foo.gox")
+}
+
+func TestClassFileGopx(t *testing.T) {
+	gopClTestFile(t, `
+var (
+	BaseClass
+	Width, Height float64
+	*AggClass
+)
+
+type BaseClass struct{
+	x int
+	y int
+}
+type AggClass struct{}
+
+func Area() float64 {
+	return Width * Height
+}
+`, `package main
+
+type BaseClass struct {
+	x int
+	y int
+}
+type AggClass struct {
+}
+type Rect struct {
+	BaseClass
+	Width  float64
+	Height float64
+	*AggClass
+}
+
+func (this *Rect) Area() float64 {
+	return this.Width * this.Height
+}
+`, "Rect.gox")
+	gopClTestFile(t, `
+import "bytes"
+var (
+	bytes.Buffer
+)
+func test(){}
+`, `package main
+
+import "bytes"
+
+type Rect struct {
+	bytes.Buffer
+}
+
+func (this *Rect) test() {
+}
+`, "Rect.gox")
+	gopClTestFile(t, `
+import "bytes"
+var (
+	*bytes.Buffer
+)
+func test(){}
+`, `package main
+
+import "bytes"
+
+type Rect struct {
+	*bytes.Buffer
+}
+
+func (this *Rect) test() {
+}
+`, "Rect.gox")
+	gopClTestFile(t, `
+import "bytes"
+var (
+	*bytes.Buffer "spec:\"buffer\""
+	a int "json:\"a\""
+	b int
+)
+func test(){}
+`, `package main
+
+import "bytes"
+
+type Rect struct {
+	*bytes.Buffer `+"`spec:\"buffer\"`"+`
+	a             int `+"`json:\"a\"`"+`
+	b             int
+}
+
+func (this *Rect) test() {
+}
+`, "Rect.gox")
+}
+
+func TestClassFileMember(t *testing.T) {
+	gopClTestFile(t, `type Engine struct {
+}
+
+func (e *Engine) EnterPointerLock() {
+}
+
+func (e *Engine) SetEnable(b bool) {
+}
+
+func Engine() *Engine {
+	return &Engine{}
+}
+
+func Test() {
+	engine.setEnable true
+	engine.enterPointerLock
+}
+`, `package main
+
+type Engine struct {
+}
+type Rect struct {
+}
+
+func (e *Engine) EnterPointerLock() {
+}
+func (e *Engine) SetEnable(b bool) {
+}
+func (this *Rect) Engine() *Engine {
+	return &Engine{}
+}
+func (this *Rect) Test() {
+	this.Engine().SetEnable(true)
+	this.Engine().EnterPointerLock()
+}
+`, "Rect.gox")
+}
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 8ddf572a..9c17a0b5 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -4113,255 +4113,6 @@ func main() {
 `)
 }
 
-func TestClassFileGopx(t *testing.T) {
-	gopClTestFile(t, `
-var (
-	BaseClass
-	Width, Height float64
-	*AggClass
-)
-
-type BaseClass struct{
-	x int
-	y int
-}
-type AggClass struct{}
-
-func Area() float64 {
-	return Width * Height
-}
-`, `package main
-
-type BaseClass struct {
-	x int
-	y int
-}
-type AggClass struct {
-}
-type Rect struct {
-	BaseClass
-	Width  float64
-	Height float64
-	*AggClass
-}
-
-func (this *Rect) Area() float64 {
-	return this.Width * this.Height
-}
-`, "Rect.gox")
-	gopClTestFile(t, `
-import "bytes"
-var (
-	bytes.Buffer
-)
-func test(){}
-`, `package main
-
-import "bytes"
-
-type Rect struct {
-	bytes.Buffer
-}
-
-func (this *Rect) test() {
-}
-`, "Rect.gox")
-	gopClTestFile(t, `
-import "bytes"
-var (
-	*bytes.Buffer
-)
-func test(){}
-`, `package main
-
-import "bytes"
-
-type Rect struct {
-	*bytes.Buffer
-}
-
-func (this *Rect) test() {
-}
-`, "Rect.gox")
-	gopClTestFile(t, `
-import "bytes"
-var (
-	*bytes.Buffer "spec:\"buffer\""
-	a int "json:\"a\""
-	b int
-)
-func test(){}
-`, `package main
-
-import "bytes"
-
-type Rect struct {
-	*bytes.Buffer `+"`spec:\"buffer\"`"+`
-	a             int `+"`json:\"a\"`"+`
-	b             int
-}
-
-func (this *Rect) test() {
-}
-`, "Rect.gox")
-}
-
-func TestOverload(t *testing.T) {
-	gopClTest(t, `
-import "github.com/goplus/gop/cl/internal/overload/foo"
-
-type Mesh struct {
-}
-
-func (p *Mesh) Name() string {
-	return "hello"
-}
-
-var (
-	m1 = &Mesh{}
-	m2 = &Mesh{}
-)
-
-foo.onKey "hello", => {
-}
-foo.onKey "hello", key => {
-}
-foo.onKey ["1"], => {
-}
-foo.onKey ["2"], key => {
-}
-foo.onKey [m1, m2], => {
-}
-foo.onKey [m1, m2], key => {
-}
-foo.onKey ["a"], ["b"], key => {
-}
-foo.onKey ["a"], [m1, m2], key => {
-}
-foo.onKey ["a"], nil, key => {
-}
-foo.onKey 100, 200
-
-n := &foo.N{}
-n.onKey "hello", => {
-}
-n.onKey "hello", key => {
-}
-n.onKey ["1"], => {
-}
-n.onKey ["2"], key => {
-}
-n.onKey [m1, m2], => {
-}
-n.onKey [m1, m2], key => {
-}
-n.onKey ["a"], ["b"], key => {
-}
-n.onKey ["a"], [m1, m2], key => {
-}
-n.onKey ["a"], nil, key => {
-}
-n.onKey 100, 200
-`, `package main
-
-import "github.com/goplus/gop/cl/internal/overload/foo"
-
-type Mesh struct {
-}
-
-func (p *Mesh) Name() string {
-	return "hello"
-}
-
-var m1 = &Mesh{}
-var m2 = &Mesh{}
-
-func main() {
-	foo.OnKey__0("hello", func() {
-	})
-	foo.OnKey__1("hello", func(key string) {
-	})
-	foo.OnKey__2([]string{"1"}, func() {
-	})
-	foo.OnKey__3([]string{"2"}, func(key string) {
-	})
-	foo.OnKey__4([]foo.Mesher{m1, m2}, func() {
-	})
-	foo.OnKey__5([]foo.Mesher{m1, m2}, func(key foo.Mesher) {
-	})
-	foo.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
-	})
-	foo.OnKey__7([]string{"a"}, []foo.Mesher{m1, m2}, func(key string) {
-	})
-	foo.OnKey__6([]string{"a"}, nil, func(key string) {
-	})
-	foo.OnKey__8(100, 200)
-	n := &foo.N{}
-	n.OnKey__0("hello", func() {
-	})
-	n.OnKey__1("hello", func(key string) {
-	})
-	n.OnKey__2([]string{"1"}, func() {
-	})
-	n.OnKey__3([]string{"2"}, func(key string) {
-	})
-	n.OnKey__4([]foo.Mesher{m1, m2}, func() {
-	})
-	n.OnKey__5([]foo.Mesher{m1, m2}, func(key foo.Mesher) {
-	})
-	n.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
-	})
-	n.OnKey__7([]string{"a"}, []foo.Mesher{m1, m2}, func(key string) {
-	})
-	n.OnKey__6([]string{"a"}, nil, func(key string) {
-	})
-	n.OnKey__8(100, 200)
-}
-`)
-}
-
-func TestClassFileMember(t *testing.T) {
-	gopClTestFile(t, `type Engine struct {
-}
-
-func (e *Engine) EnterPointerLock() {
-}
-
-func (e *Engine) SetEnable(b bool) {
-}
-
-
-func Engine() *Engine {
-	return &Engine{}
-}
-
-func Test() {
-	engine.setEnable true
-	engine.enterPointerLock
-}
-`, `package main
-
-type Engine struct {
-}
-
-func (e *Engine) EnterPointerLock() {
-}
-func (e *Engine) SetEnable(b bool) {
-}
-
-type Rect struct {
-}
-
-func (this *Rect) Engine() *Engine {
-	return &Engine{}
-}
-func (this *Rect) Test() {
-	this.Engine().SetEnable(true)
-	this.Engine().EnterPointerLock()
-}
-`, "Rect.gox")
-}
-
 func TestCommentLine(t *testing.T) {
 	gopClTestEx(t, gblConfLine, "main", `
 type Point struct {
@@ -4468,471 +4219,3 @@ func main() {
 `
 	gopClTestEx(t, &conf, "main", src, expected)
 }
-
-func TestMixedOverload(t *testing.T) {
-	gopMixedClTest(t, "main", `
-package main
-
-type Mesher interface {
-	Name() string
-}
-
-type N struct {
-}
-
-func (m *N) OnKey__0(a string, fn func()) {
-}
-
-func (m *N) OnKey__1(a string, fn func(key string)) {
-}
-
-func (m *N) OnKey__2(a []string, fn func()) {
-}
-
-func (m *N) OnKey__3(a []string, fn func(key string)) {
-}
-
-func (m *N) OnKey__4(a []Mesher, fn func()) {
-}
-
-func (m *N) OnKey__5(a []Mesher, fn func(key Mesher)) {
-}
-
-func (m *N) OnKey__6(a []string, b []string, fn func(key string)) {
-}
-
-func (m *N) OnKey__7(a []string, b []Mesher, fn func(key string)) {
-}
-
-func (m *N) OnKey__8(x int, y int) {
-}
-
-
-func OnKey__0(a string, fn func()) {
-}
-
-func OnKey__1(a string, fn func(key string)) {
-}
-
-func OnKey__2(a []string, fn func()) {
-}
-
-func OnKey__3(a []string, fn func(key string)) {
-}
-
-func OnKey__4(a []Mesher, fn func()) {
-}
-
-func OnKey__5(a []Mesher, fn func(key Mesher)) {
-}
-
-func OnKey__6(a []string, b []string, fn func(key string)) {
-}
-
-func OnKey__7(a []string, b []Mesher, fn func(key string)) {
-}
-
-func OnKey__8(x int, y int) {
-}
-
-func OnKey__9(a, b string, fn ...func(x int) int) {
-}
-
-func OnKey__a(a, b string, v ...int) {
-}
-`, `
-type Mesh struct {
-}
-
-func (p *Mesh) Name() string {
-	return "hello"
-}
-
-var (
-	m1 = &Mesh{}
-	m2 = &Mesh{}
-)
-
-OnKey "hello", => {
-}
-OnKey "hello", key => {
-}
-OnKey ["1"], => {
-}
-OnKey ["2"], key => {
-}
-OnKey [m1, m2], => {
-}
-OnKey [m1, m2], key => {
-}
-OnKey ["a"], ["b"], key => {
-}
-OnKey ["a"], [m1, m2], key => {
-}
-OnKey ["a"], nil, key => {
-}
-OnKey 100, 200
-OnKey "a", "b", x => x * x, x => {
-	return x * 2
-}
-OnKey "a", "b", 1, 2, 3
-OnKey("a", "b", [1, 2, 3]...)
-
-n := &N{}
-n.onKey "hello", => {
-}
-n.onKey "hello", key => {
-}
-n.onKey ["1"], => {
-}
-n.onKey ["2"], key => {
-}
-n.onKey [m1, m2], => {
-}
-n.onKey [m1, m2], key => {
-}
-n.onKey ["a"], ["b"], key => {
-}
-n.onKey ["a"], [m1, m2], key => {
-}
-n.onKey ["a"], nil, key => {
-}
-n.onKey 100, 200
-`, `package main
-
-type Mesh struct {
-}
-
-func (p *Mesh) Name() string {
-	return "hello"
-}
-
-var m1 = &Mesh{}
-var m2 = &Mesh{}
-
-func main() {
-	OnKey__0("hello", func() {
-	})
-	OnKey__1("hello", func(key string) {
-	})
-	OnKey__2([]string{"1"}, func() {
-	})
-	OnKey__3([]string{"2"}, func(key string) {
-	})
-	OnKey__4([]Mesher{m1, m2}, func() {
-	})
-	OnKey__5([]Mesher{m1, m2}, func(key Mesher) {
-	})
-	OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
-	})
-	OnKey__7([]string{"a"}, []Mesher{m1, m2}, func(key string) {
-	})
-	OnKey__6([]string{"a"}, nil, func(key string) {
-	})
-	OnKey__8(100, 200)
-	OnKey__9("a", "b", func(x int) int {
-		return x * x
-	}, func(x int) int {
-		return x * 2
-	})
-	OnKey__a("a", "b", 1, 2, 3)
-	OnKey__a("a", "b", []int{1, 2, 3}...)
-	n := &N{}
-	n.OnKey__0("hello", func() {
-	})
-	n.OnKey__1("hello", func(key string) {
-	})
-	n.OnKey__2([]string{"1"}, func() {
-	})
-	n.OnKey__3([]string{"2"}, func(key string) {
-	})
-	n.OnKey__4([]Mesher{m1, m2}, func() {
-	})
-	n.OnKey__5([]Mesher{m1, m2}, func(key Mesher) {
-	})
-	n.OnKey__6([]string{"a"}, []string{"b"}, func(key string) {
-	})
-	n.OnKey__7([]string{"a"}, []Mesher{m1, m2}, func(key string) {
-	})
-	n.OnKey__6([]string{"a"}, nil, func(key string) {
-	})
-	n.OnKey__8(100, 200)
-}
-`)
-}
-
-func TestMixedOverloadOp(t *testing.T) {
-	gopMixedClTest(t, "main", `package main
-
-import "fmt"
-
-type foo struct {
-}
-
-func (a *foo) Gop_Add(b *foo) *foo {
-	fmt.Println("a + b")
-	return &foo{}
-}
-func (a foo) Gop_Sub(b foo) foo {
-	fmt.Println("a - b")
-	return foo{}
-}
-func (a foo) Gop_NE(b foo) bool {
-	fmt.Println("a!=b")
-	return true
-}
-func (a foo) Gop_Neg() *foo {
-	fmt.Println("-a")
-	return &foo{}
-}
-func (a foo) Gop_Inc() {
-	fmt.Println("a++")
-}
-`, `
-var a, b foo
-var c = a - b
-var d = -a
-var e = a!=b
-`, `package main
-
-var a, b foo
-var c = (foo).Gop_Sub(a, b)
-var d = a.Gop_Neg()
-var e = (foo).Gop_NE(a, b)
-`)
-}
-
-func TestMixedVector3(t *testing.T) {
-	gopMixedClTest(t, "main", `package main
-type Vector3 struct {
-	x, y, z float64
-}
-func (a Vector3) Gop_Add__0(n int) Vector3 {
-	return Vector3{}
-}
-func (a Vector3) Gop_Add__1(n float64) Vector3 {
-	return Vector3{}
-}
-func (a Vector3) Gop_Add__2(n Vector3) Vector3 {
-	return Vector3{}
-}
-func (a *Vector3) Gop_AddAssign(n Vector3) {
-}
-
-func (a Vector3) Gop_Rcast__0() int {
-	return 0
-}
-func (a Vector3) Gop_Rcast__1() float64 {
-	return 0
-}
-
-func Vector3_Cast__0(x int) Vector3 {
-	return Vector3{}
-}
-func Vector3_Cast__1(x float64) Vector3 {
-	return Vector3{}
-}
-func Vector3_Init__0(x int) Vector3 {
-	return Vector3{}
-}
-func Vector3_Init__1(x float64) Vector3 {
-	return Vector3{}
-}
-`, `
-var a Vector3
-var b int
-var c float64
-_ = a+b
-_ = a+100
-_ = a+c
-_ = 100+a
-_ = Vector3(b)+a
-_ = b+int(a)
-a += b
-a += c
-`, `package main
-
-var a Vector3
-var b int
-var c float64
-
-func main() {
-	_ = (Vector3).Gop_Add__0(a, b)
-	_ = (Vector3).Gop_Add__0(a, 100)
-	_ = (Vector3).Gop_Add__1(a, c)
-	_ = (Vector3).Gop_Add__2(Vector3_Init__0(100), a)
-	_ = (Vector3).Gop_Add__2(Vector3_Cast__0(b), a)
-	_ = b + a.Gop_Rcast__0()
-	a.Gop_AddAssign(Vector3_Init__0(b))
-	a.Gop_AddAssign(Vector3_Init__1(c))
-}
-`)
-}
-
-func TestMixedInterfaceOverload(t *testing.T) {
-	gopMixedClTest(t, "main", `
-package main
-
-type N[T any] struct {
-	v T
-}
-
-func (m *N[T]) OnKey__0(a string, fn func()) {
-}
-
-func (m *N[T]) OnKey__1(a string, fn func(key string)) {
-}
-
-func (m *N[T]) OnKey__2(a []string, fn func()) {
-}
-
-func (m *N[T]) OnKey__3(a []string, fn func(key string)) {
-}
-
-type I interface {
-	OnKey__0(a string, fn func())
-	OnKey__1(a string, fn func(key string))
-	OnKey__2(a []string, fn func())
-	OnKey__3(a []string, fn func(key string))
-}
-`, `
-n := &N[int]{}
-n.onKey "1", => {
-}
-keys := ["1","2"]
-n.onKey keys, key => {
-	println key
-}
-n.onKey keys, => {
-	println keys
-}
-
-var i I = n
-i.onKey "1", key => {
-	println key
-}
-i.onKey ["1","2"], key => {
-	println key
-}
-`, `package main
-
-import "fmt"
-
-func main() {
-	n := &N[int]{}
-	n.OnKey__0("1", func() {
-	})
-	keys := []string{"1", "2"}
-	n.OnKey__3(keys, func(key string) {
-		fmt.Println(key)
-	})
-	n.OnKey__2(keys, func() {
-		fmt.Println(keys)
-	})
-	var i I = n
-	i.OnKey__1("1", func(key string) {
-		fmt.Println(key)
-	})
-	i.OnKey__3([]string{"1", "2"}, func(key string) {
-		fmt.Println(key)
-	})
-}
-`)
-}
-
-func TestMixedOverloadCommand(t *testing.T) {
-	gopMixedClTest(t, "main", `package main
-
-func Test__0() {
-}
-func Test__1(n int) {
-}
-type N struct {
-}
-func (p *N) Test__0() {
-}
-func (p *N) Test__1(n int) {
-}`, `
-Test
-Test 100
-var n N
-n.test
-n.test 100
-`, `package main
-
-func main() {
-	Test__0()
-	Test__1(100)
-	var n N
-	n.Test__0()
-	n.Test__1(100)
-}
-`)
-}
-
-func TestOverloadNamed(t *testing.T) {
-	gopClTest(t, `
-import "github.com/goplus/gop/cl/internal/overload/bar"
-
-var a bar.Var[int]
-var b bar.Var[bar.M]
-c := bar.Var(string)
-d := bar.Var(bar.M)
-`, `package main
-
-import "github.com/goplus/gop/cl/internal/overload/bar"
-
-var a bar.Var__0[int]
-var b bar.Var__1[map[string]any]
-
-func main() {
-	c := bar.Gopx_Var_Cast__0[string]()
-	d := bar.Gopx_Var_Cast__1[map[string]any]()
-}
-`)
-}
-
-func TestMixedOverloadNamed(t *testing.T) {
-	gopMixedClTest(t, "main", `package main
-
-const GopPackage = true
-
-type M = map[string]any
-
-type basetype interface {
-	string | int | bool | float64
-}
-
-type Var__0[T basetype] struct {
-	val T
-}
-
-type Var__1[T map[string]any] struct {
-	val T
-}
-
-func Gopx_Var_Cast__0[T basetype]() *Var__0[T] {
-	return new(Var__0[T])
-}
-
-func Gopx_Var_Cast__1[T map[string]any]() *Var__1[T] {
-	return new(Var__1[T])
-}
-`, `
-var a Var[int]
-var b Var[M]
-c := Var(string)
-d := Var(M)
-`, `package main
-
-var a Var__0[int]
-var b Var__1[map[string]interface {
-}]
-
-func main() {
-	c := Gopx_Var_Cast__0[string]()
-	d := Gopx_Var_Cast__1[map[string]interface {
-	}]()
-}
-`)
-}
diff --git a/x/build/build_test.go b/x/build/build_test.go
index b43a127f..8e2f621f 100644
--- a/x/build/build_test.go
+++ b/x/build/build_test.go
@@ -391,14 +391,13 @@ import (
 	"github.com/goplus/gop/cl/internal/spx"
 )
 
-func main() {
-	spx.Gopt_MyGame_Main(new(spx.MyGame))
-}
-
 type Cat struct {
 	spx.Sprite
 }
 
+func main() {
+	spx.Gopt_MyGame_Main(new(spx.MyGame))
+}
 func (this *Cat) Main() {
 	fmt.Println("hi")
 }