fix: variadic interface conversion in call/callBin
This commit is contained in:
14
_test/variadic9.go
Normal file
14
_test/variadic9.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func Sprintf(format string, a ...interface{}) string {
|
||||
return fmt.Sprintf(format, a...)
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(Sprintf("Hello %s", "World!"))
|
||||
}
|
||||
|
||||
// Output:
|
||||
// Hello World!
|
||||
@@ -801,17 +801,18 @@ func call(n *node) {
|
||||
values = append(values, func(f *frame) reflect.Value { return f.data[ind] })
|
||||
}
|
||||
default:
|
||||
var arg *itype
|
||||
if variadic >= 0 && i >= variadic {
|
||||
arg = n.child[0].typ.arg[variadic].val
|
||||
} else {
|
||||
arg = n.child[0].typ.arg[i]
|
||||
}
|
||||
if c.kind == basicLit || c.rval.IsValid() {
|
||||
var argType reflect.Type
|
||||
if variadic >= 0 && i >= variadic {
|
||||
argType = n.child[0].typ.arg[variadic].val.TypeOf()
|
||||
} else {
|
||||
argType = n.child[0].typ.arg[i].TypeOf()
|
||||
}
|
||||
argType := arg.TypeOf()
|
||||
convertLiteralValue(c, argType)
|
||||
}
|
||||
switch {
|
||||
case len(n.child[0].typ.arg) > i && n.child[0].typ.arg[i].cat == interfaceT:
|
||||
case arg.cat == interfaceT:
|
||||
values = append(values, genValueInterface(c))
|
||||
case isRecursiveType(c.typ, c.typ.rtype):
|
||||
values = append(values, genValueRecursiveInterfacePtrValue(c))
|
||||
@@ -1072,7 +1073,7 @@ func callBin(n *node) {
|
||||
values = append(values, genFunctionWrapper(c))
|
||||
case interfaceT:
|
||||
values = append(values, genValueInterfaceValue(c))
|
||||
case arrayT:
|
||||
case arrayT, variadicT:
|
||||
switch c.typ.val.cat {
|
||||
case interfaceT:
|
||||
values = append(values, genValueInterfaceArray(c))
|
||||
|
||||
Reference in New Issue
Block a user