]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] go/types, types2: only use fileVersion if 1.21 or greater
authorMichael Matloob <matloob@golang.org>
Wed, 7 Aug 2024 17:09:18 +0000 (13:09 -0400)
committerCarlos Amedee <carlos@golang.org>
Mon, 12 Aug 2024 20:21:53 +0000 (20:21 +0000)
commit63b0f805cd83f97c43a45e9558d00513c2399fbf
treef10b69cf3acc7199dd0724eb01e3e4b5888d031a
parent7adb01220584115365acc9ebda0317d530288a1a
[release-branch.go1.23] go/types, types2: only use fileVersion if 1.21 or greater

Only honor //go:build language version downgrades if the version
specified is 1.21 or greater. Before 1.21 the version in //go:build
lines didn't have the meaning of setting the file's language version.

This fixes an issue that was appearing in GOPATH builds: Go 1.23 started
providing -lang versions to the compiler in GOPATH mode (among other
places) which it wasn't doing before.

For example, take a go file with a //go:build line specifying go1.10.
If that file used a 1.18 feature, that use would compile fine with a Go
1.22 toolchain. But, before this change, it would produce an error when
compiling with the 1.23 toolchain because it set the language version to
1.10 and disallowed the 1.18 feature. This breaks backwards
compatibility: when the build tag was added, it did not have the meaning
of restricting the language version.

Fixes #68658

Change-Id: I4ac2b45a981cd019183d52ba324ba8f0fed93a8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/603895
Reviewed-by: Robert Griesemer <gri@google.com>
Commit-Queue: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/604935
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/check.go
src/go/types/api_test.go
src/go/types/check.go
src/internal/types/testdata/check/go1_20_19.go
src/internal/types/testdata/check/go1_21_19.go
src/internal/types/testdata/check/go1_21_22.go [new file with mode: 0644]
src/internal/types/testdata/check/go1_22_21.go [new file with mode: 0644]
src/internal/types/testdata/fixedbugs/issue66285.go
test/fixedbugs/issue63489a.go