GOEXPERIMENT=rangefunc still enables it for all Go modules.
Otherwise only enable in Go 1.23 source files.
More work remains but it will be done in follow-up issues.
Fixes #61405.
Change-Id: Icad64942deb152ee65444e4d7be289814a8a0b6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/557835
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
}
return typ.elem, nil, "", false, true
case *Signature:
- // TODO(gri) when this becomes enabled permanently, add version check
- if !buildcfg.Experiment.RangeFunc {
- break
+ if !buildcfg.Experiment.RangeFunc && allowVersion != nil && !allowVersion(go1_23) {
+ return bad("requires go1.23 or later")
}
assert(typ.Recv() == nil)
switch {
go1_20 = asGoVersion("go1.20")
go1_21 = asGoVersion("go1.21")
go1_22 = asGoVersion("go1.22")
+ go1_23 = asGoVersion("go1.23")
// current (deployed) Go version
go_current = asGoVersion(fmt.Sprintf("go1.%d", goversion.Version))
}
return typ.elem, nil, "", false, true
case *Signature:
- // TODO(gri) when this becomes enabled permanently, add version check
- if !buildcfg.Experiment.RangeFunc {
- break
+ if !buildcfg.Experiment.RangeFunc && allowVersion != nil && !allowVersion(go1_23) {
+ return bad("requires go1.23 or later")
}
assert(typ.Recv() == nil)
switch {
go1_20 = asGoVersion("go1.20")
go1_21 = asGoVersion("go1.21")
go1_22 = asGoVersion("go1.22")
+ go1_23 = asGoVersion("go1.23")
// current (deployed) Go version
go_current = asGoVersion(fmt.Sprintf("go1.%d", goversion.Version))
-// -goexperiment=rangefunc
-
// Copyright 2023 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.