Skip to content
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

cmd/vet: audit / update vet analyzer handling of generic code #48704

Open
8 of 28 tasks
findleyr opened this issue Sep 30, 2021 · 9 comments
Open
8 of 28 tasks

cmd/vet: audit / update vet analyzer handling of generic code #48704

findleyr opened this issue Sep 30, 2021 · 9 comments

Comments

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 30, 2021

Umbrella issue: we need to verify that the vet analyzers in x/tools are well behaved with generic code, before they are vendored into the standard library as part of the Go 1.18 release cycle.

The majority of the analyzers require no additional logic for the new language constructs. In most of these cases, we should still add test coverage. This coverage needs to be added both in x/tools, and in cmd/vet/testdata. We can start with x/tools and add tests to cmd/vet once our changes have been vendored.

In some cases, analyzers will require new logic to handle type parameters. For example, the printf analyzer could consider the structural restrictions on a type parameter (e.g. interface { ~int }), and offer diagnostics if a particular verb is incompatible with this structural restriction (I put together a proof of concept CL for this). But the solution in that CL is not obviously correct: we can't know whether a type argument implements fmt.Formatter. Where such non-trivial decisions are required, we should have a separate propsal issue that will be referenced here.

I'll keep this top comment updated with the current state of analyzers:

CC @timothy-king @golang/tools-team

(N.B.: I'm filing this issue during quiet week, because we need it to track ongoing CLs. Please note that we might not be responsive to discussion about vet changes this week, but that there will be time for discussion later).

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 1, 2021

Change https://golang.org/cl/353210 mentions this issue: go/analysis/passes/unmarshal: allow unmarshalling to a type parameter

gopherbot pushed a commit to golang/tools that referenced this issue Oct 4, 2021
We can also unmarshal data to a type parameter, in addition to a pointer
and an interface.

This analyzer probably requires more discussion, but this solution
should be sufficient for now.

Updates golang/go#48704

Change-Id: I333f919109295e80a04e59df131713553cdbe612
Reviewed-on: https://go-review.googlesource.com/c/tools/+/353210
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 5, 2021

Change https://golang.org/cl/353550 mentions this issue: go/analysis/passes/atomic: add a test that uses typeparams

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 5, 2021

Change https://golang.org/cl/353629 mentions this issue: go/analysis/passes/bools: add typeparams test

gopherbot pushed a commit to golang/tools that referenced this issue Oct 5, 2021
This atomic check simply inspects whether sync/atomic.Add*
are used and LHS looks identical to the first arg of the call.
In the current implementation, this does not require handling
of type params. This test shows the addition of typeparams
doesn't crash the vet.

Update golang/go#48704

Change-Id: I79f9d782595f6bf2db82237afdbef1ffdf6f808e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/353550
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 7, 2021

Change https://golang.org/cl/354610 mentions this issue: go/analysis/passes/assign: add typeparams test

gopherbot pushed a commit to golang/tools that referenced this issue Oct 10, 2021
This CL adds a test for the assign pass that involves use of generics.

Update golang/go#48704

Change-Id: I355e73130c54bdc2363c686a5b28fe3140a307b5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/354610
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
jmesyou added a commit to jmesyou/golang-tools that referenced this issue Oct 20, 2021
This CL adds a test for unused results inside a function using generics.

Update golang/go#48704
jmesyou added a commit to jmesyou/golang-tools that referenced this issue Oct 20, 2021
This CL adds a test for unused results inside a function using generics.

Update golang/go#48704
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 20, 2021

Change https://golang.org/cl/357411 mentions this issue: go/analysis/passes/unusedresult: add test for typeparams

jmesyou added a commit to jmesyou/golang-tools that referenced this issue Oct 20, 2021
This CL adds a test for unused results inside a function using generics.

Update golang/go#48704
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 20, 2021

Change https://golang.org/cl/357412 mentions this issue: go/analysis/passes/deepequalerrors: add typeparams test

gopherbot pushed a commit to golang/tools that referenced this issue Oct 21, 2021
This CL adds a test for the assign pass that involves use of generics.

Update golang/go#48704

Change-Id: I1aa51aed24d63d42b6b0150d64925b97dfd59a92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357412
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Cherry Mui <cherryyz@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 21, 2021

Change https://golang.org/cl/357777 mentions this issue: go/analysis/passes/ctrlflow: add typeparams test

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 21, 2021

Change https://golang.org/cl/357756 mentions this issue: go/analysis/passes/composite: update for generics

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 22, 2021

Change https://golang.org/cl/357758 mentions this issue: go/analysis/passes/shift: update for generics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants