diff options
| author | Rob Pike <r@golang.org> | 2012-04-12 15:57:09 +1000 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2012-04-12 15:57:09 +1000 |
| commit | 2d0d3d8f9efadcad71537b046e31f45a4b0a7844 (patch) | |
| tree | 3208060580605171c62eb48f5d6ac10a02a9afef /src/pkg/text/template/parse/parse_test.go | |
| parent | e6c5e2a36358465ab5038d8af9e70f3b98d5ba88 (diff) | |
| download | go-2d0d3d8f9efadcad71537b046e31f45a4b0a7844.tar.xz | |
text/template: catch unexported fields during parse
It's a common error to reference unexported field names in templates,
especially for newcomers. This catches the error at parse time rather than
execute time so the rare few who check errors will notice right away.
These were always an error, so the net behavior is unchanged.
Should break no existing code, just identify the error earlier.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6009048
Diffstat (limited to 'src/pkg/text/template/parse/parse_test.go')
| -rw-r--r-- | src/pkg/text/template/parse/parse_test.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pkg/text/template/parse/parse_test.go b/src/pkg/text/template/parse/parse_test.go index b2e788238d..fb98613fe1 100644 --- a/src/pkg/text/template/parse/parse_test.go +++ b/src/pkg/text/template/parse/parse_test.go @@ -230,6 +230,7 @@ var parseTests = []parseTest{ {"invalid punctuation", "{{printf 3, 4}}", hasError, ""}, {"multidecl outside range", "{{with $v, $u := 3}}{{end}}", hasError, ""}, {"too many decls in range", "{{range $u, $v, $w := 3}}{{end}}", hasError, ""}, + {"unexported field", "{{.local}}", hasError, ""}, // Equals (and other chars) do not assignments make (yet). {"bug0a", "{{$x := 0}}{{$x}}", noError, "{{$x := 0}}{{$x}}"}, {"bug0b", "{{$x = 1}}{{$x}}", hasError, ""}, |
