]> Cypherpunks repositories - gostls13.git/commit
go/types: don't fail fast on Go version errors
authorAlan Donovan <adonovan@google.com>
Tue, 26 Mar 2024 16:45:36 +0000 (12:45 -0400)
committerAlan Donovan <adonovan@google.com>
Wed, 3 Apr 2024 22:50:48 +0000 (22:50 +0000)
commit8121604559035734c9677d5281bbdac8b1c17a1e
tree6e07682870d188e04dd2bbdf949ab565d83e50ca
parentaf43932c20d5b59cdffca45406754dbccbb46dfa
go/types: don't fail fast on Go version errors

Many tools (especially in the IDE) rely on type information
being computed even for packages that have some type errors.
Previously, there were two early (error) exits in checkFiles
that violated this invariant, one related to FakeImportC
and one related to a too-new Config.GoVersion.
(The FakeImportC one is rarely encountered in practice,
but the GoVersion one, which was recently downgraded from
a panic by CL 507975, was a source of crashes
due to incomplete type information.)

This change moves both of those errors out of checkFiles
so that they report localized errors and don't obstruct
type checking. A test exercises the errors, and that
type annotations are produced.

Also, we restructure and document checkFiles to make clear
that it is never supposed to stop early.

Updates #66525

Change-Id: I9c6210e30bbf619f32a21157f17864b09cfb5cf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/574495
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/resolver.go
src/go/types/api_test.go
src/go/types/check.go
src/go/types/resolver.go
src/internal/types/errors/code_string.go
src/internal/types/errors/codes.go