Prevent variadic arguments from being wrapped as function

Fixes #1375
This commit is contained in:
cclerget
2022-04-07 14:24:07 +02:00
committed by GitHub
parent 371103f0d1
commit c93b836c77
2 changed files with 39 additions and 1 deletions

38
_test/issue-1375.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import "fmt"
type Option func(*Struct)
func WithOption(opt string) Option {
return func(s *Struct) {
s.opt = opt
}
}
type Struct struct {
opt string
}
func New(opts ...Option) *Struct {
s := new(Struct)
for _, opt := range opts {
opt(s)
}
return s
}
func (s *Struct) ShowOption() {
fmt.Println(s.opt)
}
func main() {
opts := []Option{
WithOption("test"),
}
s := New(opts...)
s.ShowOption()
}
// Output:
// test

View File

@@ -1235,7 +1235,7 @@ func call(n *node) {
values = append(values, genValueInterface(c))
case isInterfaceBin(arg):
values = append(values, genInterfaceWrapper(c, arg.rtype))
case isFuncSrc(arg):
case isFuncSrc(arg) && !hasVariadicArgs:
values = append(values, genValueNode(c))
default:
values = append(values, genValue(c))