}
// Add final value if necessary.
if final.IsValid() {
- argv[i] = final
+ t := typ.In(typ.NumIn() - 1)
+ if typ.IsVariadic() {
+ t = t.Elem()
+ }
+ argv[i] = s.validateType(final, t)
}
result := fun.Call(argv)
// If we have an error that is not nil, stop execution and return that error to the caller.
switch typ.Kind() {
case reflect.Interface, reflect.Ptr, reflect.Chan, reflect.Map, reflect.Slice, reflect.Func:
// An untyped nil interface{}. Accept as a proper nil value.
+ // TODO: Can we delete the other types in this list? Should we?
value = reflect.Zero(typ)
default:
s.errorf("invalid value; expected %s", typ)
{"bug7a", "{{3 2}}", "", tVal, false},
{"bug7b", "{{$x := 1}}{{$x 2}}", "", tVal, false},
{"bug7c", "{{$x := 1}}{{3 | $x}}", "", tVal, false},
+ // Pipelined arg was not being type-checked.
+ {"bug8a", "{{3|oneArg}}", "", tVal, false},
+ {"bug8b", "{{4|dddArg 3}}", "", tVal, false},
}
func zeroArgs() string {
return "oneArg=" + a
}
+func dddArg(a int, b ...string) string {
+ return fmt.Sprintln(a, b)
+}
+
// count returns a channel that will deliver n sequential 1-letter strings starting at "a"
func count(n int) chan string {
if n == 0 {
b := new(bytes.Buffer)
funcs := FuncMap{
"count": count,
+ "dddArg": dddArg,
"oneArg": oneArg,
"typeOf": typeOf,
"vfunc": vfunc,