From 50c7783f599d3af0e65f1c301c7ff05f6876def7 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 19 Jan 2017 13:19:22 -0500 Subject: [PATCH] text/template: remove duplicate logic in conditional It looks like this conditional may have been refactored at some point, but the logic was still very confusing. The outer conditional checks if the function is variadic, so there's no need to verify that in the result. Additionally, since the function isn't variadic, there is no reason to permit the function call if the number of input arguments is less than the function signature requires. Change-Id: Ia957cf83d1c900c08dd66384efcb74f0c368422e Reviewed-on: https://go-review.googlesource.com/35491 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/text/template/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text/template/exec.go b/src/text/template/exec.go index ea964dc2bcd..7d92bd9d36e 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -628,7 +628,7 @@ func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, a if numIn < numFixed { s.errorf("wrong number of args for %s: want at least %d got %d", name, typ.NumIn()-1, len(args)) } - } else if numIn < typ.NumIn()-1 || !typ.IsVariadic() && numIn != typ.NumIn() { + } else if numIn != typ.NumIn() { s.errorf("wrong number of args for %s: want %d got %d", name, typ.NumIn(), len(args)) } if !goodFunc(typ) {