aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-10-05 11:41:40 -0700
committerIan Lance Taylor <iant@golang.org>2021-10-05 21:22:16 +0000
commit8444a545e3d38c2e470df5035ef4b5a9365aaefc (patch)
treec2bc6a8dbca193af6b2327829116da9a963f426c /src/text/template/exec.go
parent55e7f7e12d46292e130a3b48c86bac2a6e5a1739 (diff)
downloadgo-8444a545e3d38c2e470df5035ef4b5a9365aaefc.tar.xz
text/template: only unwrap final and/or value
In the last CL I missed the fact that except for the final value the code already unwraps the argument. For #31103 Change-Id: Ic9099aeb50c6b3322fc14a90ac8026c1d8cb1698 Reviewed-on: https://go-review.googlesource.com/c/go/+/354091 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/text/template/exec.go')
-rw-r--r--src/text/template/exec.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 9a4c9e29dd..9ae6fdc3cc 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -728,13 +728,21 @@ func (s *state) evalCall(dot, fun reflect.Value, isBuiltin bool, node parse.Node
for _, arg := range args {
v = s.evalArg(dot, argType, arg).Interface().(reflect.Value)
if truth(v) == (name == "or") {
- return unwrap(v)
+ // This value was already unwrapped
+ // by the .Interface().(reflect.Value).
+ return v
}
}
if final != missingVal {
- v = s.validateType(final, argType)
+ // The last argument to and/or is coming from
+ // the pipeline. We didn't short circuit on an earlier
+ // argument, so we are going to return this one.
+ // We don't have to evaluate final, but we do
+ // have to check its type. Then, since we are
+ // going to return it, we have to unwrap it.
+ v = unwrap(s.validateType(final, argType))
}
- return unwrap(v)
+ return v
}
// Build the arg list.