Closed
Description
What version of Go are you using (go version
)?
go version go1.20.5 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/jmooring/.cache/go-build" GOENV="/home/jmooring/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/jmooring/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/jmooring/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/snap/go/current" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/snap/go/current/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.5" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build988921665=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package main
import (
"os"
"text/template"
)
func main() {
a := [1]string{"value"}
t := `
{{ $k := "" }}
{{ $v := "" }}
{{ range $k, $v = . }}
{{ $k }} = {{ $v }}
{{ end }}
`
tmpl, err := template.New("test").Parse(t)
if err != nil {
panic(err)
}
err = tmpl.Execute(os.Stdout, a)
if err != nil {
panic(err)
}
}
What did you expect to see?
0 = value
What did you see instead?
value = 0
Other
This is a regression, introduced when fixing #56490.