]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: do not mutate arguments in NewChecker
authorRobert Findley <rfindley@google.com>
Fri, 7 Jul 2023 15:20:16 +0000 (11:20 -0400)
committerRobert Findley <rfindley@google.com>
Fri, 7 Jul 2023 19:58:56 +0000 (19:58 +0000)
commitac9137f8d312c3a6916ab71de61b05c192c455f0
tree59055abfc03e9acefca888857d99549ffe903abe
parent158d11196f732e4c80b03240548bdd373e6a9eff
go/types, types2: do not mutate arguments in NewChecker

CL 507975 resulted in new data races (as reported in #61212), because
the pkg argument to NewChecker was mutated.

Fix this by deferring the recording of the goVersion in pkg until type
checking is actually initiated via a call to Checker.Files.
Additionally, modify types2/check.go to bring it in sync with the
changes in go/types/check.go, and generate the new version_test.go from
the types2 file.

Also move parsing the version into checkFiles, for simplicity.

Fixes #61212

Change-Id: I15edb6c2cff3085622fe7c6a3b0dab531d27bd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/508439
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/version_test.go [new file with mode: 0644]
src/go/types/check.go
src/go/types/generate_test.go
src/go/types/version_test.go