Skip to content

Commit

Permalink
cl: fix compileCallArgs recover error for overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Oct 11, 2024
1 parent 8fee8a4 commit b65a745
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cl/compile_gop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
`)
}
6 changes: 6 additions & 0 deletions cl/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b65a745

Please sign in to comment.