]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: record Config.GoVersion for reporting in Package.GoVersion method
authorRuss Cox <rsc@golang.org>
Wed, 5 Jul 2023 16:08:51 +0000 (12:08 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 6 Jul 2023 13:09:19 +0000 (13:09 +0000)
commitb490bdc27d5576e5ccdac33755c0156d609e1bb9
tree322ea08dc4d914893473d5f715dc184929cac241
parent36ea4f9680f8296f1c7d0cf7dbb1b3a9d572754a
go/types: record Config.GoVersion for reporting in Package.GoVersion method

Clients of go/types, such as analyzers, may need to know which
specific Go version a package is written for. Record that information
in the Package and expose it using the new GoVersion method.

Update parseGoVersion to handle the new Go versions that may
be passed around starting in Go 1.21.0: versions like "go1.21.0"
and "go1.21rc2". This is not strictly necessary today, but it adds some
valuable future-proofing.

While we are here, change NewChecker from panicking on invalid
version to saving an error for returning later from Files.
Go versions are now likely to be coming from a variety of sources,
not just hard-coded in calls to NewChecker, making a panic
inappropriate.

For #61174.
Fixes #61175.

Change-Id: Ibe41fe207c1b6e71064b1fe448ac55776089c541
Reviewed-on: https://go-review.googlesource.com/c/go/+/507975
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
api/go1.21.txt
src/cmd/compile/internal/types2/package.go
src/cmd/compile/internal/types2/sizeof_test.go
src/cmd/compile/internal/types2/version.go
src/go/build/deps_test.go
src/go/types/check.go
src/go/types/package.go
src/go/types/sizeof_test.go
src/go/types/version.go
src/go/types/version_test.go [new file with mode: 0644]