mirror of
https://github.com/golang/go
synced 2025-04-30 02:37:46 +00:00
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>
26 lines
335 B
Go
26 lines
335 B
Go
// build
|
|
|
|
// Copyright 2025 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
type T int
|
|
|
|
const K T = 5
|
|
|
|
type P struct {
|
|
a [K]*byte
|
|
}
|
|
|
|
//go:noinline
|
|
func f(p *P) {
|
|
for i := range K {
|
|
p.a[i] = nil
|
|
}
|
|
}
|
|
func main() {
|
|
f(nil)
|
|
}
|