// Special case for the "call" builtin.
// Insert the name of the callee function as the first argument.
if isBuiltin && name == "call" {
- calleeName := args[0].String()
+ var calleeName string
+ if len(args) == 0 {
+ // final must be present or we would have errored out above.
+ calleeName = final.String()
+ } else {
+ calleeName = args[0].String()
+ }
argv = append([]reflect.Value{reflect.ValueOf(calleeName)}, argv...)
fun = reflect.ValueOf(call)
}
{"Interface Call", `{{stringer .S}}`, "foozle", map[string]any{"S": bytes.NewBufferString("foozle")}, true},
{".ErrFunc", "{{call .ErrFunc}}", "bla", tVal, true},
{"call nil", "{{call nil}}", "", tVal, false},
+ {"empty call", "{{call}}", "", tVal, false},
+ {"empty call after pipe valid", "{{.ErrFunc | call}}", "bla", tVal, true},
+ {"empty call after pipe invalid", "{{1 | call}}", "", tVal, false},
// Erroneous function calls (check args).
{".BinaryFuncTooFew", "{{call .BinaryFunc `1`}}", "", tVal, false},