]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add cast in range loop final value computation
authorKeith Randall <khr@golang.org>
Thu, 24 Apr 2025 15:38:56 +0000 (08:38 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 24 Apr 2025 18:02:26 +0000 (11:02 -0700)
commit3452d80da3cf4f08da0f5905b1aa19cec475936e
treefd4d18d93afe50ee0ba033ef1b681340a4294970
parent3009566a46f19e9c94df4cf51cc374763698cba0
cmd/compile: add cast in range loop final value computation

When replacing a loop where the iteration variable has a named type,
we need to compute the last iteration value as i = T(len(a)-1), not
just i = len(a)-1.

Fixes #73491

Change-Id: Ic1cc3bdf8571a40c10060f929a9db8a888de2b70
Reviewed-on: https://go-review.googlesource.com/c/go/+/667815
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/walk/range.go
test/fixedbugs/issue73491.go [new file with mode: 0644]