compiler: count locals for vararg inline functions
This commit is contained in:
parent
abee3b5b05
commit
f7b9861c11
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue