-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.19] cmd/go: refuse to build Go 1.22 code
With #60078 accepted, we expect Go 1.22 will have different for loop semantics than Go 1.19 did. Go 1.19 is already unsupported, but add a check anyway, just to help catch some mistakes and usage of old Go toolchains beyond their end-of-support. Note that Go 1.19 can keep being used indefinitely with pre-Go 1.22 code. This change only makes it refuse to build code that says it needs Go 1.22 semantics, because Go 1.19 does not provide those. Cherry-pick of the change from the Go 1.20 branch. For #60078. Change-Id: I75118d6fbd0cc08a6bc309aca54c389a255ba7dc Reviewed-on: https://go-review.googlesource.com/c/go/+/518675 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/518815 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Bypass: Russ Cox <rsc@golang.org>
- Loading branch information
Showing
3 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
! go build | ||
stderr '^m: cannot compile Go 1.22 code$' | ||
|
||
cd dep | ||
! go build | ||
stderr '^m: cannot compile Go 1.22 code$' | ||
|
||
cd ../dep20 | ||
go build | ||
|
||
cd ../dep21 | ||
go build | ||
|
||
-- go.mod -- | ||
module m | ||
go 1.22 | ||
|
||
-- p.go -- | ||
package p | ||
|
||
-- dep/go.mod -- | ||
module dep | ||
go 1.19 | ||
require m v1.0.0 | ||
replace m v1.0.0 => ../ | ||
|
||
-- dep/p.go -- | ||
package p | ||
|
||
import "m" | ||
|
||
-- dep20/go.mod -- | ||
module dep | ||
go 1.20 | ||
|
||
-- dep20/p.go -- | ||
package p | ||
|
||
-- dep21/go.mod -- | ||
module dep | ||
go 1.21 | ||
|
||
-- dep21/p.go -- | ||
package p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters