nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: goplus/gop
Pull request #1789 (2024-03-05 19:26:54)

inMainPkg


Patch:
diff --git a/cl/compile.go b/cl/compile.go
index bde0459b..6ae75ca1 100644
--- a/cl/compile.go
+++ b/cl/compile.go
@@ -654,16 +654,20 @@ func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
 	gox.InitThisGopPkg(pkg.Types)
 }
 
+func inMainPkg(f *ast.File) bool {
+	return f.Name.Name == "main"
+}
+
 func getEntrypoint(f *ast.File) string {
 	switch {
 	case f.IsProj:
 		return "MainEntry"
 	case f.IsClass:
 		return "Main"
-	case f.Name.Name != "main":
-		return "init"
-	default:
+	case inMainPkg(f):
 		return "main"
+	default:
+		return "init"
 	}
 }
 
@@ -845,7 +849,7 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
 	}
 	if d := f.ShadowEntry; d != nil {
 		d.Name.Name = getEntrypoint(f)
-	} else if f.IsProj && !conf.NoAutoGenMain && f.Name.Name == "main" {
+	} else if f.IsProj && !conf.NoAutoGenMain && inMainPkg(f) {
 		var entry = getEntrypoint(f)
 		var hasEntry bool
 		for _, decl := range f.Decls {
diff --git a/cl/internal/spx3/spx3.go b/cl/internal/spx3/spx3.go
index 3255e2ea..8f1d8574 100644
--- a/cl/internal/spx3/spx3.go
+++ b/cl/internal/spx3/spx3.go
@@ -38,7 +38,7 @@ func (p *Sprite) Name() string {
 	return "sprite"
 }
 
-func (p *Sprite) initSprite() {}
+func (p *Sprite) initSprite(name string) {}
 
-func Gopt_Game_Main(game interface{ initGame() }, workers ...interface{ initSprite() }) {
+func Gopt_Game_Main(game interface{ initGame() }, workers ...interface{ initSprite(name string) }) {
 }


Test patch:
diff --git a/cl/run_test.go b/cl/run_test.go
index 7f31b1b7..c117fe98 100644
--- a/cl/run_test.go
+++ b/cl/run_test.go
@@ -62,7 +62,7 @@ func getBytes(stdout, stderr io.Writer) (o iBytes, ok bool) {
 	return
 }
 
-func goRun(t *testing.T, code []byte) string {
+func goRun(_ *testing.T, code []byte) string {
 	idx := atomic.AddInt64(&tmpFileIdx, 1)
 	infile := tmpDir + strconv.FormatInt(idx, 10) + ".go"
 	err := os.WriteFile(infile, []byte(code), 0666)
Repository: goplus/gop
Pull request #1799 (2024-03-08 18:24:34)

TestErrStringLit


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index d81cdf4c..7a49b06c 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -971,7 +971,12 @@ func compileStringLitEx(ctx *blockCtx, cb *gogen.CodeBuilder, lit *ast.BasicLit)
 			compileExpr(ctx, v, flags)
 			t := cb.Get(-1).Type
 			if t.Underlying() != types.Typ[types.String] {
-				cb.Member("string", gogen.MemberFlagAutoProperty)
+				if _, err := cb.Member("string", gogen.MemberFlagAutoProperty); err != nil {
+					if e, ok := err.(*gogen.CodeError); ok {
+						err = ctx.newCodeErrorf(v.Pos(), "%s.string%s", ctx.LoadExpr(v), e.Msg)
+					}
+					ctx.handleErr(err)
+				}
 			}
 			pos = v.End()
 		default:


Test patch:
diff --git a/cl/error_msg_test.go b/cl/error_msg_test.go
index ff7dd02b..cc27271a 100644
--- a/cl/error_msg_test.go
+++ b/cl/error_msg_test.go
@@ -509,6 +509,12 @@ func (p *[]byte) foo() {
 `)
 }
 
+func TestErrStringLit(t *testing.T) {
+	codeErrorTest(t, `bar.gop:2:9: [].string undefined (type []interface{} has no field or method string)`, `
+echo "${[]}"
+`)
+}
+
 func TestErrStructLit(t *testing.T) {
 	codeErrorTest(t,
 		`bar.gop:3:39: too many values in struct{x int; y string}{...}`, `
Repository: goplus/gop
Pull request #1810 (2024-03-09 15:55:20)

cl: EnvExpr


Patch:
diff --git a/ast/walk.go b/ast/walk.go
index 4ce089ff..0cea28fe 100644
--- a/ast/walk.go
+++ b/ast/walk.go
@@ -456,6 +456,9 @@ func Walk(v Visitor, node Node) {
 		Walk(v, n.Name)
 		walkExprList(v, n.Funcs)
 
+	case *EnvExpr:
+		Walk(v, n.Name)
+
 	default:
 		panic(fmt.Sprintf("ast.Walk: unexpected node type %T", n))
 	}
diff --git a/cl/expr.go b/cl/expr.go
index 7a49b06c..b261dcf7 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -188,6 +188,21 @@ find:
 	return
 }
 
+func compileEnvExpr(ctx *blockCtx, v *ast.EnvExpr) {
+	cb := ctx.cb
+	if ctx.isClass { // in a Go+ class file
+		if recv := classRecv(cb); recv != nil {
+			if gopMember(cb, recv, "Gop_Env", v) == nil {
+				name := v.Name
+				cb.Val(name.Name, name).CallWith(1, 0, v)
+				return
+			}
+		}
+	}
+	invalidVal(cb)
+	ctx.handleErrorf(v.Pos(), "operator $%v undefined", v.Name)
+}
+
 func classRecv(cb *gogen.CodeBuilder) *types.Var {
 	if fn := cb.Func(); fn != nil {
 		sig := fn.Ancestor().Type().(*types.Signature)
@@ -346,6 +361,8 @@ func compileExpr(ctx *blockCtx, expr ast.Expr, inFlags ...int) {
 		compileErrWrapExpr(ctx, v, 0)
 	case *ast.FuncType:
 		ctx.cb.Typ(toFuncType(ctx, v, nil, nil), v)
+	case *ast.EnvExpr:
+		compileEnvExpr(ctx, v)
 	default:
 		log.Panicf("compileExpr failed: unknown - %T\n", v)
 	}
@@ -938,6 +955,10 @@ func compileBasicLit(ctx *blockCtx, v *ast.BasicLit) {
 	}
 }
 
+func invalidVal(cb *gogen.CodeBuilder) {
+	cb.Val(&gogen.Element{Type: types.Typ[types.Invalid]})
+}
+
 func basicLit(cb *gogen.CodeBuilder, v *ast.BasicLit) {
 	cb.Val(&goast.BasicLit{Kind: gotoken.Token(v.Kind), Value: v.Value}, v)
 }


Test patch:
diff --git a/cl/compile_spx_test.go b/cl/compile_spx_test.go
index bca91346..bb284bc7 100644
--- a/cl/compile_spx_test.go
+++ b/cl/compile_spx_test.go
@@ -259,6 +259,36 @@ func (this *bar) Classfname() string {
 `)
 }
 
+func TestEnvOp(t *testing.T) {
+	gopSpxTest(t, `
+echo ${PATH}, $id
+`, ``, `package main
+
+import (
+	"fmt"
+	"github.com/goplus/gop/cl/internal/spx"
+)
+
+type bar struct {
+	spx.Sprite
+	*index
+}
+type index struct {
+	*spx.MyGame
+}
+
+func (this *index) MainEntry() {
+	fmt.Println(this.Gop_Env("PATH"), this.Gop_Env("id"))
+}
+func main() {
+	spx.Gopt_MyGame_Main(new(index))
+}
+func (this *bar) Classfname() string {
+	return "bar"
+}
+`)
+}
+
 func TestSpxGopEnv(t *testing.T) {
 	gopSpxTest(t, `
 echo "${PATH}"
diff --git a/cl/error_msg_test.go b/cl/error_msg_test.go
index cc27271a..5c268cd9 100644
--- a/cl/error_msg_test.go
+++ b/cl/error_msg_test.go
@@ -509,6 +509,15 @@ func (p *[]byte) foo() {
 `)
 }
 
+func TestErrEnvOp(t *testing.T) {
+	codeErrorTest(t, `bar.gop:2:6: operator $name undefined`, `
+echo ${name}
+`)
+	codeErrorTest(t, `bar.gop:2:1: operator $id undefined`, `
+$id
+`)
+}
+
 func TestErrStringLit(t *testing.T) {
 	codeErrorTest(t, `bar.gop:2:9: [].string undefined (type []interface{} has no field or method string)`, `
 echo "${[]}"
Repository: goplus/gop
Pull request #1817 (2024-03-11 05:24:36)

gmxProject.hasMain


Patch:
diff --git a/cl/classfile.go b/cl/classfile.go
index 2eecbcd5..9a101c85 100644
--- a/cl/classfile.go
+++ b/cl/classfile.go
@@ -54,6 +54,15 @@ type gmxProject struct {
 	hasScheds  bool
 	gameIsPtr  bool
 	isTest     bool
+	hasMain_   bool
+}
+
+func (p *gmxProject) hasMain() bool {
+	if !p.hasMain_ {
+		imps := p.pkgImps
+		p.hasMain_ = len(imps) > 0 && imps[0].TryRef("GopTestClass") != nil
+	}
+	return p.hasMain_
 }
 
 func (p *gmxProject) getScheds(cb *gogen.CodeBuilder) []goast.Stmt {
@@ -143,6 +152,7 @@ func loadClass(ctx *pkgCtx, pkg *gogen.Package, file string, f *ast.File, conf *
 			log.Panicln("multiple project files found:", tname, p.gameClass)
 		}
 		p.gameClass = tname
+		p.hasMain_ = f.HasShadowEntry()
 	} else {
 		p.sptypes = append(p.sptypes, tname)
 	}
@@ -173,7 +183,7 @@ func spxTryRef(spx gogen.PkgRef, typ string) (obj types.Object, isPtr bool) {
 func spxRef(spx gogen.PkgRef, typ string) (obj gogen.Ref, isPtr bool) {
 	obj, isPtr = spxTryRef(spx, typ)
 	if obj == nil {
-		panic(spx.Path() + "." + typ + " not found")
+		panic(spx.Types.Name() + "." + typ + " not found")
 	}
 	return
 }
@@ -246,20 +256,34 @@ func genTestFunc(pkg *gogen.Package, name, testType, param, paramType string) {
 		End()
 }
 
-func gmxCheckProjs(pkg *gogen.Package, ctx *pkgCtx) (proj *gmxProject, multi bool) {
+func gmxCheckProjs(pkg *gogen.Package, ctx *pkgCtx) (*gmxProject, bool) {
+	var projMain, projNoMain *gmxProject
+	var multiMain, multiNoMain bool
 	for _, v := range ctx.projs {
 		if v.isTest {
 			continue
-		} else if proj != nil {
-			multi = true
+		}
+		if v.hasMain() {
+			if projMain != nil {
+				multiMain = true
+			} else {
+				projMain = v
+			}
 		} else {
-			proj = v
+			if projNoMain != nil {
+				multiNoMain = true
+			} else {
+				projNoMain = v
+			}
 		}
 		if v.game != nil { // just to make testcase happy
 			gmxProjMain(pkg, ctx, v)
 		}
 	}
-	return
+	if projMain != nil {
+		return projMain, multiMain
+	}
+	return projNoMain, multiNoMain
 }
 
 func gmxProjMain(pkg *gogen.Package, parent *pkgCtx, proj *gmxProject) {


Test patch:
diff --git a/cl/builtin_test.go b/cl/builtin_test.go
index 5837b440..59316168 100644
--- a/cl/builtin_test.go
+++ b/cl/builtin_test.go
@@ -253,6 +253,17 @@ func TestErrParseTypeEmbedName(t *testing.T) {
 }
 
 func TestGmxCheckProjs(t *testing.T) {
+	_, multi := gmxCheckProjs(nil, &pkgCtx{
+		projs: map[string]*gmxProject{
+			".a": {hasMain_: true}, ".b": {hasMain_: true},
+		},
+	})
+	if !multi {
+		t.Fatal("gmxCheckProjs: not multi?")
+	}
+}
+
+func TestGmxCheckProjs2(t *testing.T) {
 	_, multi := gmxCheckProjs(nil, &pkgCtx{
 		projs: map[string]*gmxProject{
 			".a": {}, ".b": {},
Repository: goplus/gop
Pull request #1832 (2024-04-01 02:46:21)

cl: compileExpr/compileExprLHS panic code error


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index b261dcf7..914402b8 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -23,7 +23,6 @@ import (
 	"go/types"
 	"log"
 	"math/big"
-	"reflect"
 	"strconv"
 	"strings"
 	"syscall"
@@ -248,7 +247,7 @@ func compileExprLHS(ctx *blockCtx, expr ast.Expr) {
 	case *ast.StarExpr:
 		compileStarExprLHS(ctx, v)
 	default:
-		log.Panicln("compileExpr failed: unknown -", reflect.TypeOf(v))
+		panic(ctx.newCodeErrorf(v.Pos(), "compileExprLHS failed: unknown - %T", expr))
 	}
 	if rec := ctx.recorder(); rec != nil {
 		rec.recordExpr(ctx, expr, true)
@@ -364,7 +363,7 @@ func compileExpr(ctx *blockCtx, expr ast.Expr, inFlags ...int) {
 	case *ast.EnvExpr:
 		compileEnvExpr(ctx, v)
 	default:
-		log.Panicf("compileExpr failed: unknown - %T\n", v)
+		panic(ctx.newCodeErrorf(v.Pos(), "compileExpr failed: unknown - %T", v))
 	}
 	if rec := ctx.recorder(); rec != nil {
 		rec.recordExpr(ctx, expr, false)


Test patch:
diff --git a/cl/builtin_test.go b/cl/builtin_test.go
index 59316168..bdae13aa 100644
--- a/cl/builtin_test.go
+++ b/cl/builtin_test.go
@@ -92,11 +92,14 @@ func TestCompileLambda2(t *testing.T) {
 
 func TestCompileExpr(t *testing.T) {
 	defer func() {
-		if e := recover(); e != "compileExpr failed: unknown - *ast.Ellipsis\n" {
-			t.Fatal("compileExpr:", e)
+		if e := recover(); e != nil {
+			if ce := e.(*gogen.CodeError); ce.Msg != "compileExpr failed: unknown - *ast.Ellipsis" {
+				t.Fatal("compileExpr:", ce.Msg)
+			}
 		}
 	}()
-	compileExpr(nil, &ast.Ellipsis{})
+	ctx := &blockCtx{pkgCtx: &pkgCtx{}}
+	compileExpr(ctx, &ast.Ellipsis{})
 }
 
 func TestCompileStmt(t *testing.T) {
diff --git a/cl/error_msg_test.go b/cl/error_msg_test.go
index 5c268cd9..ddc65610 100644
--- a/cl/error_msg_test.go
+++ b/cl/error_msg_test.go
@@ -1049,3 +1049,17 @@ type
 a := 1
 `)
 }
+
+func TestCompileExprError(t *testing.T) {
+	codeErrorTestAst(t, "main", "bar.go", `bar.go:5:1: compileExpr failed: unknown - *ast.BadExpr`, `
+func Foo(){}
+func _() {
+	Foo(
+}
+`)
+	codeErrorTestAst(t, "main", "bar.go", `bar.go:3:2: compileExprLHS failed: unknown - *ast.StructType`, `
+func _() {
+	struct() = nil
+}
+`)
+}
Repository: goplus/gop
Pull request #1833 (2024-04-01 08:45:29)

update:correct anonymous overloaded function naming
- [x] correct compiled overloaded function declaration when have a anonymous overloaded function

```go
// origin.gop
func MulInt(a,b int) int  {
	return a * b
}
func MulFloat(a,b float64) float64  {
	return a * b
}
func Mul = (
	func(a string,b string){}
	MulInt
	MulFloat
)
```
The overloaded function declaration generated in the previous version lacks the location of the anonymous overloaded function.
```go
// before autogen.go
const _ = true
const Gopo_Mul = "MulInt,MulFloat"

func Mul__0(a string, b string) {
}

func MulInt(a int, b int) int {
	return a * b
}

func MulFloat(a float64, b float64) float64 {
	return a * b
}
```
```go
// current autogen.go
const _ = true
const Gopo_Mul = ",MulInt,MulFloat"
....
```


Patch:
diff --git a/cl/compile.go b/cl/compile.go
index c5948cfd..2b8340b9 100644
--- a/cl/compile.go
+++ b/cl/compile.go
@@ -1088,6 +1088,7 @@ func preloadFile(p *gogen.Package, ctx *blockCtx, f *ast.File, goFile string, ge
 				case *ast.FuncLit:
 					checkOverloadFunc(d)
 					name1 := overloadFuncName(name.Name, idx)
+					onames = append(onames, "") // const Gopo_xxx = "xxxInt,,xxxFloat"
 					ctx.lbinames = append(ctx.lbinames, name1)
 					preloadFuncDecl(&ast.FuncDecl{
 						Doc:  d.Doc,


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 7e7c2b63..7939cb92 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -376,6 +376,46 @@ func main() {
 `)
 }
 
+func TestOverloadFunc3(t *testing.T) {
+	gopClTest(t, `
+func addInt(a, b int) int {
+	return a + b
+}
+
+func addFloat(a, b float64) float64 {
+	return a * b
+}
+
+func add = (
+	func (a,b string) string { return a + b }
+	addInt
+	addFloat
+)
+
+println add(100, 7)
+println add(1.2, 3.14)
+`, `package main
+
+import "fmt"
+
+const Gopo_add = ",addInt,addFloat"
+
+func add__0(a string, b string) string {
+	return a + b
+}
+func addInt(a int, b int) int {
+	return a + b
+}
+func addFloat(a float64, b float64) float64 {
+	return a * b
+}
+func main() {
+	fmt.Println(addInt(100, 7))
+	fmt.Println(addFloat(1.2, 3.14))
+}
+`)
+}
+
 func TestOverload(t *testing.T) {
 	gopClTest(t, `
 import "github.com/goplus/gop/cl/internal/overload/foo"
Repository: goplus/gop
Pull request #1860 (2024-04-13 13:13:37)

ast: fix (*ast.File).End check shadow no entry
fix (*ast.File).End bad result if classfile add shadow func Classfname.

example `get.yap` ast.File.End return  last shadow func Classfname.End()


Patch:
diff --git a/ast/ast.go b/ast/ast.go
index 9f3753a5..1a87ed9b 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -1156,8 +1156,12 @@ func (f *File) Pos() token.Pos {
 
 // End returns position of first character immediately after the node.
 func (f *File) End() token.Pos {
-	if n := len(f.Decls); n > 0 {
-		return f.Decls[n-1].End()
+	for n := len(f.Decls) - 1; n >= 0; n-- {
+		d := f.Decls[n]
+		if fn, ok := d.(*FuncDecl); ok && fn.Shadow && fn != f.ShadowEntry {
+			continue
+		}
+		return d.End()
 	}
 	return f.Name.End()
 }


Test patch:
diff --git a/cl/builtin_test.go b/cl/builtin_test.go
index ce7133df..016ca223 100644
--- a/cl/builtin_test.go
+++ b/cl/builtin_test.go
@@ -26,6 +26,7 @@ import (
 	"github.com/goplus/gogen/cpackages"
 	"github.com/goplus/gogen/packages"
 	"github.com/goplus/gop/ast"
+	"github.com/goplus/gop/parser"
 	"github.com/goplus/gop/token"
 	"github.com/goplus/mod/modfile"
 )
@@ -687,4 +688,16 @@ func testPanic(t *testing.T, panicMsg string, doPanic func()) {
 	})
 }
 
+func TestClassFileEnd(t *testing.T) {
+	fset := token.NewFileSet()
+	f, err := parser.ParseFile(fset, "get.yap", `json {"id": ${id} }`, parser.ParseGoPlusClass)
+	if err != nil {
+		t.Fatal(err)
+	}
+	f.Decls = append(f.Decls, astFnClassfname(&gmxClass{clsfile: "get"}))
+	if f.End() != f.ShadowEntry.End() {
+		t.Fatal("class file end not shadow entry")
+	}
+}
+
 // -----------------------------------------------------------------------------
Repository: goplus/gop
Pull request #1862 (2024-04-16 13:46:02)

cl.GetFileClassType: fix isProj must check name is main


Patch:
diff --git a/cl/classfile.go b/cl/classfile.go
index 06572f0c..0356b363 100644
--- a/cl/classfile.go
+++ b/cl/classfile.go
@@ -97,11 +97,10 @@ func ClassNameAndExt(file string) (name, clsfile, ext string) {
 }
 
 // GetFileClassType get ast.File classType
-func GetFileClassType(file *ast.File, filename string, lookupClass func(ext string) (c *Project, ok bool)) (classType string, isTest bool, ok bool) {
+func GetFileClassType(file *ast.File, filename string, lookupClass func(ext string) (c *Project, ok bool)) (classType string, isTest bool) {
 	if file.IsClass {
 		var ext string
 		classType, _, ext = ClassNameAndExt(filename)
-		ok = true
 		if file.IsNormalGox {
 			isTest = strings.HasSuffix(ext, "_test.gox")
 			if !isTest && classType == "main" {
@@ -110,7 +109,7 @@ func GetFileClassType(file *ast.File, filename string, lookupClass func(ext stri
 		} else {
 			isTest = strings.HasSuffix(ext, "test.gox")
 		}
-		if file.IsProj {
+		if file.IsProj && classType == "main" {
 			if gt, ok := lookupClass(ext); ok {
 				classType = gt.Class
 			}
diff --git a/load.go b/load.go
index 127d3397..d5a6fcbd 100644
--- a/load.go
+++ b/load.go
@@ -405,7 +405,7 @@ var (
 // -----------------------------------------------------------------------------
 
 // GetFileClassType get gop module file classType.
-func GetFileClassType(mod *gopmod.Module, file *ast.File, filename string) (classType string, isTest bool, ok bool) {
+func GetFileClassType(mod *gopmod.Module, file *ast.File, filename string) (classType string, isTest bool) {
 	return cl.GetFileClassType(file, filename, mod.LookupClass)
 }
 


Test patch:
diff --git a/cl/builtin_test.go b/cl/builtin_test.go
index 016ca223..3cebd7f4 100644
--- a/cl/builtin_test.go
+++ b/cl/builtin_test.go
@@ -351,6 +351,10 @@ func TestFileClassType(t *testing.T) {
 		{true, false, false, "Abc_yap.gox", "Abc", false, true},
 		{true, false, true, "main_yap.gox", "App", false, true},
 
+		{true, false, true, "abc_yap.gox", "abc", false, true},
+		{true, false, true, "Abc_yap.gox", "Abc", false, true},
+		{true, false, true, "main_yap.gox", "App", false, true},
+
 		{true, false, false, "abc_ytest.gox", "case_abc", true, true},
 		{true, false, false, "Abc_ytest.gox", "caseAbc", true, true},
 		{true, false, true, "main_ytest.gox", "App", true, true},
@@ -376,10 +380,7 @@ func TestFileClassType(t *testing.T) {
 	}
 	for _, test := range tests {
 		f := &ast.File{IsClass: test.isClass, IsNormalGox: test.isNormalGox, IsProj: test.isProj}
-		classType, isTest, found := GetFileClassType(f, test.fileName, lookupClass)
-		if found != test.found {
-			t.Fatalf("%v found classType want %v, got %v.", test.fileName, test.found, found)
-		}
+		classType, isTest := GetFileClassType(f, test.fileName, lookupClass)
 		if isTest != test.isTest {
 			t.Fatalf("%v check classType isTest want %v, got %v.", test.fileName, test.isTest, isTest)
 		}
Repository: goplus/gop
Pull request #1991 (2024-10-11 03:10:28)

cl: fix compileCallArgs recover error for overloads


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index 7b76ede1..dec29bf9 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -753,6 +753,12 @@ func fnCall(ctx *blockCtx, v *ast.CallExpr, flags gogen.InstrFlags, extra int) e
 }
 
 func compileCallArgs(ctx *blockCtx, pfn *gogen.Element, fn *fnType, v *ast.CallExpr, ellipsis bool, flags gogen.InstrFlags) (err error) {
+	defer func() {
+		r := recover()
+		if r != nil {
+			err = ctx.recoverErr(r, v)
+		}
+	}()
 	var needInferFunc bool
 	for i, arg := range v.Args {
 		switch expr := arg.(type) {


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 73874dfe..be836b38 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1570,3 +1570,30 @@ func main() {
 }
 `)
 }
+
+func TestOverlodOptions(t *testing.T) {
+	gopMixedClTest(t, "main", `
+package main
+
+type PlayOptions struct {
+	Action int
+	Wait   bool
+	Loop   bool
+}
+type Game struct {
+}
+func (g *Game) Play__0(options *PlayOptions) {
+}
+func (g *Game) Play__1(name string, options *PlayOptions) {
+}
+`, `
+g := &Game{}
+g.play "work", { Action: 0, Loop: true }
+`, `package main
+
+func main() {
+	g := &Game{}
+	g.Play__1("work", &PlayOptions{Action: 0, Loop: true})
+}
+`)
+}
Repository: goplus/gop
Pull request #2014 (2024-11-12 14:41:46)

cl: TestEmbedField


Patch:
diff --git a/go.mod b/go.mod
index 828ee1ac..4a815a6b 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	github.com/fsnotify/fsnotify v1.8.0
-	github.com/goplus/gogen v1.16.2
+	github.com/goplus/gogen v1.16.3-0.20241112142719-46167891a7ee
 	github.com/goplus/llgo v0.9.7
 	github.com/goplus/mod v0.13.12
 	github.com/qiniu/x v1.13.10
diff --git a/go.sum b/go.sum
index 7105c5a3..41a6e1a4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
 github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
 github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
-github.com/goplus/gogen v1.16.2 h1:u8uaNGUW0csXp9Ar6/1SzRfPRebvVhiqTvFHvOsnTZY=
-github.com/goplus/gogen v1.16.2/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
+github.com/goplus/gogen v1.16.3-0.20241112142719-46167891a7ee h1:lwV/kdyMI18qF70vd+ur2/rAdmoA+Zy+c/btdDiiYt8=
+github.com/goplus/gogen v1.16.3-0.20241112142719-46167891a7ee/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
 github.com/goplus/llgo v0.9.7 h1:LRF2Fq9ts4QrVxOPZufexalbIoJ1oiBERjCWQ45wxbg=
 github.com/goplus/llgo v0.9.7/go.mod h1:5Fs+08NslqofJ7xtOiIXugkurYOoQvY02ZkFNWA1uEI=
 github.com/goplus/mod v0.13.12 h1:Trwk6j3i9VvBuW6/9ZxmkoFlEL2v3HKQu0Na1c6DAdw=


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index be836b38..04742bf2 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1597,3 +1597,36 @@ func main() {
 }
 `)
 }
+
+func TestEmbedField(t *testing.T) {
+	gopClTest(t, `package main
+
+type Info struct {
+	id int
+}
+type T struct {
+	Info
+	id string
+}
+func demo(t *T) {
+	t.id = "0"
+}
+func main() {
+}
+`, `package main
+
+type Info struct {
+	id int
+}
+type T struct {
+	Info
+	id string
+}
+
+func demo(t *T) {
+	t.id = "0"
+}
+func main() {
+}
+`)
+}
Repository: goplus/gop
Pull request #2030 (2024-12-06 01:24:16)

update gogen for overload check untyped args
update gogen for fix https://github.com/goplus/spx/issues/465


Patch:
diff --git a/go.mod b/go.mod
index cbe3b4a8..10b3a11e 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	github.com/fsnotify/fsnotify v1.8.0
-	github.com/goplus/gogen v1.16.3
+	github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f
 	github.com/goplus/llgo v0.9.8
 	github.com/goplus/mod v0.13.12
 	github.com/qiniu/x v1.13.10
diff --git a/go.sum b/go.sum
index e1e847ac..cead13c2 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
 github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
 github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
-github.com/goplus/gogen v1.16.3 h1:nNkV1b6zd89d/UhMb4bZHcEfdAHtPaadrJFXNcoUITI=
-github.com/goplus/gogen v1.16.3/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
+github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f h1:+CwzStluc1MGjEQbR5CQOXWOqlBLYnaeECKcSXrHYKg=
+github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
 github.com/goplus/llgo v0.9.8 h1:9qFO5sEYzTXYixNL9m9qDNfI2kjtnU3bPMf5hOwQlME=
 github.com/goplus/llgo v0.9.8/go.mod h1:1phqPJEgr/uw59PRz/NB7s54OoP+NGjC6pz0HovT5JY=
 github.com/goplus/mod v0.13.12 h1:Trwk6j3i9VvBuW6/9ZxmkoFlEL2v3HKQu0Na1c6DAdw=


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 04742bf2..90bbdd66 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1630,3 +1630,37 @@ func main() {
 }
 `)
 }
+
+func TestOverloadUntyped(t *testing.T) {
+	gopMixedClTest(t, "main", `
+package main
+
+type specialObj int
+type SpriteName string
+
+type SpriteImpl struct {
+}
+
+func (p *SpriteImpl) turn(v any) {
+}
+func (p *SpriteImpl) TurnTo__0(sprite *SpriteImpl) {
+}
+func (p *SpriteImpl) TurnTo__1(sprite SpriteName) {
+}
+func (p *SpriteImpl) TurnTo__2(obj specialObj) {
+}
+func (p *SpriteImpl) TurnTo__3(degree float64) {
+}
+`, `
+p := &SpriteImpl{}
+p.turnTo 180.0
+p.turnTo 180.1
+`, `package main
+
+func main() {
+	p := &SpriteImpl{}
+	p.TurnTo__2(180.0)
+	p.TurnTo__3(180.1)
+}
+`)
+}