-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: false positive printf-like function detection #26486
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
Comments
Looking at the current repo, line 423 is
That will cause the |
AFAICT, if s == "" {
s = strings.Repeat("%v ", len(va))
} |
@cznic Quite right, sorry for missing that. So what is happening here is that vet is seeing that the arguments to Perhaps it is possible to modify the formatting checks to not attempt to warn if the function modifies its parameters. Let me see how difficult that would be to implement. |
Change https://golang.org/cl/125039 mentions this issue: |
I don't think it's that simple. Couldn't this could turn off checking for too many benign functions, such as this one:
|
@robpike I'm more or less assuming that false positives must be avoided. I don't see how to reasonably handle your example while still not issuing a warning for the We could decide that we are going to warn for |
@ianlancetaylor I'm not convinced your starting point is the right one. I want to keep false positives low but not at the point of disabling checks too broadly. The |
Because we run |
What about temporarily applying a conservative fix for 1.11, and looking for a better solution for 1.12? If I remember correctly, the printf checks were completely disabled for a similar reason in 1.10 and are coming back in 1.11. |
I came here to suggest what @mvdan says. If you want to make progress, I suppose the CL should land, but:
|
- go vet in Go v1.11 identifies `Say()` as a print wrapper - go vet will then fail for `Say("%")` because this is not a valid Sprintf template - Because of golang/go#26486, changing the way that the functon is written will work around the vet issue - I have added a comment documenting that this is not ideal in golang/go#26555 (comment)
- go vet in Go v1.11 identifies `Say()` as a print wrapper - go vet will then fail for `Say("%")` because this is not a valid Sprintf template - Because of golang/go#26486, changing the way that the functon is written will work around the vet issue - I have added a comment documenting that this is not ideal in golang/go#26555 (comment)
go version: 1.11 beta 1 (regression compared to 1.10 branch)
OS version: fedora rawhide
The go package
github.com/cznic/ql
can't compile its tests with go 1.11 beta 1, which is a regression compared to go 1.10.I've reported this issue originally here:
cznic/ql#203
However, I agree with the developer that this vet error looks like a false-positive, since the function in question (included below) doesn't actually need formatting directives.
function triggering this vet error:
error message:
The text was updated successfully, but these errors were encountered: