You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vet command's bool checker reports progressively more errors as the redundancy in an expression grows. For 7 copies, it reports 1+2+3+4+5+6 errors, because it reports all the errors in each subtree.
$ cat a.go
package a
const k = 1
var _ = k==1||k==1||k==1||k==1||k==1||k==1||k==1
$ vet a.go
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
a.go:5: redundant or: k == 1 || k == 1
$ vet a.go 2>&1 | wc -l
21
In realistic cases the redundancy is always n=2 so vet only prints n(n-1)/2 = 1 error and there's no problem in practice. However, vet's test suite exercises deeper expressions that lead to redundant errors that are ignored by vet's current test harness because they all match the correct regexp. The new x/tools/go/analysis test harness is more precise and requires multiple expectations for multiple errors. I do not wish to change the checker logic during the migration to the new API, so the task of this issue is to fix the checker logic and remove the workaround from the tests.
The text was updated successfully, but these errors were encountered:
It might be easier to have vet just stop reporting errors on a given line after some small count is reached. Also more general. This sort of issue with error reporting is an evergreen.
And rename from "bool" to "bools".
Using analysistest unearthed a minor bug,
github.com/golang/go/issues/28086.
To avoid complicating the diff we work
around it in the tests for now.
Change-Id: I682f33506de778dfdfe97841cd2b16e3d47062b8
Reviewed-on: https://go-review.googlesource.com/c/140737
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
The vet command's bool checker reports progressively more errors as the redundancy in an expression grows. For 7 copies, it reports 1+2+3+4+5+6 errors, because it reports all the errors in each subtree.
In realistic cases the redundancy is always n=2 so vet only prints n(n-1)/2 = 1 error and there's no problem in practice. However, vet's test suite exercises deeper expressions that lead to redundant errors that are ignored by vet's current test harness because they all match the correct regexp. The new x/tools/go/analysis test harness is more precise and requires multiple expectations for multiple errors. I do not wish to change the checker logic during the migration to the new API, so the task of this issue is to fix the checker logic and remove the workaround from the tests.
The text was updated successfully, but these errors were encountered: