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: check for duplicate input to some binary ops #15586
Comments
The following operators as well: > >= < <= |
Only 4 examples in the whole tree would argue against. |
Some data points from staticcheck:
|
You report a false positive rate of over 40%. That is high. |
The issue with those false positives is that they were hundreds of tests like these:
(from github.com/rocky/go-eval/checkbinaryexpr_typed_gen_test.go) It's part of a Go interpreter project, with hundreds of code-gened tests like those, and the project had several forks. If you ignore that particular project, you're left with about 20 false positives among all matches. Those are in generated code, in tests of |
@josharian , see the draft CL. |
CL https://golang.org/cl/23350 mentions this issue. |
This is marked |
Done. We try to get to NeedsDecision labels in our proposal review meetings, but I guess we never made it here. :-/ |
[moved from #15570]
@dominikh's staticcheck found some bugs in the standard library -- see #15570. This issue is to consider whether it's worth adding a vet check along the same lines.
The check would be to look for expressions of the form (x BOP x), where:
These expressions are either redundant or have a constant value (with some very rare exceptions, like division and the smallest negative integer), which indicates that they are probably a mistake, and in any case would be better written in another way.
cc @robpike for opinions
cc @valyala in case you are interested in playing with more vet checks :)
The text was updated successfully, but these errors were encountered: