aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-01-27 14:14:05 -0500
committerRuss Cox <rsc@golang.org>2017-02-09 14:58:40 +0000
commit06637fb3146cd7fd19efc7463cd9d2c0006bff67 (patch)
treee9d2145a1bef03a7b14988e401b4f32069f14446 /src/text/template/exec_test.go
parente4371fb179ad69cbd057f2430120843948e09f2f (diff)
downloadgo-06637fb3146cd7fd19efc7463cd9d2c0006bff67.tar.xz
text/template: fix method lookup on addressable nil pointer
Fixes #18816. Change-Id: I4f8f1cac2680dbde492c56d3a5a038577605e7c1 Reviewed-on: https://go-review.googlesource.com/36542 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/text/template/exec_test.go')
-rw-r--r--src/text/template/exec_test.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go
index 5892b27391..9f7e637c19 100644
--- a/src/text/template/exec_test.go
+++ b/src/text/template/exec_test.go
@@ -147,6 +147,8 @@ var tVal = &T{
Tmpl: Must(New("x").Parse("test template")), // "x" is the value of .X
}
+var tSliceOfNil = []*T{nil}
+
// A non-empty interface.
type I interface {
Method0() string
@@ -337,6 +339,7 @@ var execTests = []execTest{
"true", tVal, true},
{".NilOKFunc not nil", "{{call .NilOKFunc .PI}}", "false", tVal, true},
{".NilOKFunc nil", "{{call .NilOKFunc nil}}", "true", tVal, true},
+ {"method on nil value from slice", "-{{range .}}{{.Method1 1234}}{{end}}-", "-1234-", tSliceOfNil, true},
// Function call builtin.
{".BinaryFunc", "{{call .BinaryFunc `1` `2`}}", "[1=2]", tVal, true},