diff options
| author | Ian Lance Taylor <iant@golang.org> | 2022-10-31 15:58:06 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-11-02 18:43:27 +0000 |
| commit | be7068fb0804f661515c678bee9224b90b32869a (patch) | |
| tree | 4fbfe9031091009a97bd41b8591f3a4e11ab83e9 /src/text/template/exec_test.go | |
| parent | c53390b078b4d3b18e3aca8970d4b31d4d82cce1 (diff) | |
| download | go-be7068fb0804f661515c678bee9224b90b32869a.tar.xz | |
text/template: correct assignment, not declaration, in range
We were mishandling {{range $i = .}}, treating it as though it were
{{range $i := .}}. That happened to work if $i were the most recently
declared variable, but not otherwise.
Fixes #56490
Change-Id: I222a009d671d86c06a980a54388e05f12101c00b
Reviewed-on: https://go-review.googlesource.com/c/go/+/446795
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/text/template/exec_test.go')
| -rw-r--r-- | src/text/template/exec_test.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 6bfae3d319..6b163f0ae1 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -692,6 +692,8 @@ var execTests = []execTest{ {"bug18a", "{{eq . '.'}}", "true", '.', true}, {"bug18b", "{{eq . 'e'}}", "true", 'e', true}, {"bug18c", "{{eq . 'P'}}", "true", 'P', true}, + + {"issue56490", "{{$i := 0}}{{$x := 0}}{{range $i = .AI}}{{end}}{{$i}}", "5", tVal, true}, } func zeroArgs() string { |
