-
-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audit staticcheck for GODEBUG=gotypesalias=1 support #1523
Comments
(Updated; sorry about that. Feel free to delete your note to unsubscribe.) |
Thanks for the detailed description and resources. I'll get started on this as soon as possible. |
dominikh
added a commit
that referenced
this issue
Apr 24, 2024
Go 1.22 introduced go/types.Alias, a node that explicitly encodes type aliases. GODEBUG=gotypesalias=1 enables this behavior. In Go 1.23, that setting will become the new default. Update all code that compares types (via equality, string equality, or type assertions) to account for aliases. Most checks don't require changes, as they operate on underlying types. For the remainder, a mix of types.Unalias and explicit handling of aliases is necessary. Closes: gh-1523
This was referenced Jun 21, 2024
gopherbot
pushed a commit
to golang/tools
that referenced
this issue
Oct 29, 2024
Also: remove t.Skips related to its types.Alias support, which is done (dominikh/go-tools#1523). A follow-up change will revert the workaround for missing buildir support for range-over-func (dominikh/go-tools#1494), which is also done. Change-Id: Ic3dff1e2d9616bc12d0ee2c98e81ca747491c0cc Reviewed-on: https://go-review.googlesource.com/c/tools/+/586076 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go 1.22 introduced the
types.Alias
type, but did not start creating instances of them, unlessGODEBUG=gotypesalias=1
. Go 1.23 will start creating instances of them, unlessGODEBUG=gotypesalias=0
. The effective default value of GODEBUG is determined by the version of thego
directive in the go.mod file of the application. It is inevitably an incompatible change.Staticcheck will need to handle
types.Alias
values. In most cases, it is sufficient to ensure that every type switch and type assertion that tests for a particulartypes.Type
removes anyAlias
constructors, either by callingUnalias
orUnderlying
as the situation requires. (You may find this package useful during the transition.) In some cases, for example when a name or source location is required, the application can do a better job by not discarding aliases, but handling them with additional logic.You may find it helpful to:
Let us know if we can help.
(In due course, aliases will support type parameters, like Named types. We expect this change will be straightforward since it is compatible.)
Related:
cc @findleyr
The text was updated successfully, but these errors were encountered: