diff --git a/pkg/compiler/func_scope.go b/pkg/compiler/func_scope.go index 3f5891b8c..eabc09c79 100644 --- a/pkg/compiler/func_scope.go +++ b/pkg/compiler/func_scope.go @@ -131,6 +131,11 @@ func (c *codegen) countLocalsInline(decl *ast.FuncDecl, pkg *types.Package, f *f return false } if inner, ok := c.funcs[name]; ok && canInline(name) { + sig, ok := c.typeOf(n.Fun).(*types.Signature) + if !ok { + info := c.buildInfo.program.Package(pkg.Path()) + sig = info.Types[n.Fun].Type.(*types.Signature) + } for i := range n.Args { switch n.Args[i].(type) { case *ast.Ident: @@ -139,6 +144,10 @@ func (c *codegen) countLocalsInline(decl *ast.FuncDecl, pkg *types.Package, f *f size++ } } + // Variadic with direct var args. + if sig.Variadic() && !n.Ellipsis.IsValid() { + size++ + } innerSz, _ := c.countLocalsInline(inner.decl, inner.pkg, inner) size += innerSz }