diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go index 73874dfee..be836b389 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}) +} +`) +} diff --git a/cl/expr.go b/cl/expr.go index 7b76ede18..dec29bf9b 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) {