-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: false positive for user-defined verbs #36564
Comments
If the type being printed implements Or maybe it never worked, but it should. |
Can I help with this? |
@tiriplicamihai go for it |
I will try to investigate tomorrow evening (EET here). |
Hey @kortschak vet seems to properly work. I wrote this dummy example and the command runs without any issues: package main
import (
"fmt"
"os"
)
type A struct{}
func (_ *A) Format(f fmt.State, c rune) {}
func main() {
out, _ := os.Create("cucu")
defer out.Close()
a := &A{}
fmt.Fprintf(out, "%a", a)
} I looked a bit over your code and it seems the dependency does not actually implement the Formatter interface: https://github.com/biogo/biogo/blob/master/seq/seq.go (at least not in the version I found on GH). My 2c here is that you either change '%a' to an allowed verb or submit a request to have sequnece implement the @josharian I think this issue can be closed. |
I’ll let @kortschak confirm and close if appropriate. |
It's not correct that the type doesn't implement |
It does however explain what the problem is. Clearly vet is not considering whether the arg to You can see this kind of behaviour in vet for the common verbs here
This does not cause a vet warning, but the equivalent without the In src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go,
|
If that's acceptable, I can send a CL. Presumably this goes to x/tools and will then get vendored in to the project source from there. |
Change https://golang.org/cl/217180 mentions this issue: |
We have no way of knowing the concrete type of an interface value; it might be a fmt.Formatter. To avoid false positives, assume that all interface values are fmt.Formatters. Updates golang/go#36564 Change-Id: Iaf18ba2794e4d3095d0018502c1c6c459a360b42 Reviewed-on: https://go-review.googlesource.com/c/tools/+/217180 Reviewed-by: Rob Pike <r@golang.org>
It looks like this is done. @kortschak can this be closed? |
Yes, I think that's OK. Maybe check with @robpike that that is a complete fix. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
No complaint.
What did you see instead?
Vet failure causing test failure (well, it would be a test failure if there were a test).
Additional information
The
%a
verb is non-standard verb, an addition to the biological sequence types provided by bíogo through theirfmt.Formatter
satisfaction. However, they have been in existence since 2013 and when they were included (as is still true), there was no documentation stating that only verbs listed in the fmt package for the built-in types should be used.The text was updated successfully, but these errors were encountered: