Description
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 proposal issue that will be referenced here.
I'll keep this top comment updated with the current state of analyzers:
- asmdecl
- No need to handle type params until (if ever) we allow calling generic functions from assembly
- assign
- atomic
- bools
- buildtag
- No update needed.
- cgocall
- composite
- check constituents of the type set
- https://golang.org/cl/357756
- copylock
- find uses of locks via type parameters
- https://golang.org/cl/360234
- ctrlflow
- errorsas
- framepointer
- (no update needed)
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- handle instantiated funcs
- https://golang.org/cl/359894
- printf
- shift
- Check constituents of the type set
- https://golang.org/cl/357758
- sigchanyzer
- No update needed.
- stdmethods
- stringintconv
- consider constituent type sets of type parameters
- https://golang.org/cl/359294
- structtag
- No update required.
- testinggoroutine
- detect bad calls via instantiated funcs
- https://golang.org/cl/359401
- tests
- report test funcs with type parameters
- https://golang.org/cl/359494
- unmarshal
- unreachable
- No update required.
- unsafeptr
- https://golang.org/cl/360174
- Could do more, but it will probably have to wait for 1.19.
- unusedresult
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).