go/src/text/template
Daniel Martí 218f4572f5 text/template: make reflect.Value indirections more robust
Always shadow or modify the original parameter name. With code like:

	func index(item reflect.Value, ... {
		v := indirectInterface(item)

It was possible to incorrectly use 'item' and 'v' later in the function,
which could result in subtle bugs. This is precisely the kind of mistake
that led to #36199.

Instead, don't keep both the old and new reflect.Value variables in
scope. Always shadow or modify the original variable.

While at it, simplify the signature of 'length', to receive a
reflect.Value directly and save a few redundant lines.

Change-Id: I01416636a9d49f81246d28b91aca6413b1ba1aa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/212117
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Roberto Clapis <robclap8@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2020-02-24 09:16:18 +00:00
..
parse text/template/parse: remove redundant return 2020-01-23 23:07:10 +00:00
testdata
doc.go text/template: support all comparable types in eq 2019-09-25 09:13:11 +00:00
example_test.go
examplefiles_test.go
examplefunc_test.go
exec.go text/template: add error check for parenthesized first argument in pipeline 2019-11-12 05:06:42 +00:00
exec_test.go text/template: indirect interfaces before slicing 2019-12-19 13:52:09 +00:00
funcs.go text/template: make reflect.Value indirections more robust 2020-02-24 09:16:18 +00:00
helper.go html/template, text/template: document glob semantics 2019-06-17 21:53:49 +00:00
multi_test.go
option.go
template.go text/template: remove an incorrect comment and clarify docs for AddParseTree 2019-12-17 11:10:58 +00:00