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
doc: vet check included in gc needs to be documented #26109
Comments
That's not a vet error message. That file is failing the type-checking phase that precedes the vet checks. The reason the file fails typecheking is that this:
doesn't count as using the |
Root cause is the decision taken on #21287 (cmd/vet: decide how to handle type checking failure). I quote:
This happened in go1.10, but AFAIK it wasn't documented in the release notes. I don't see it here: https://golang.org/doc/go1.10#vet We could document this in the 1.11 release notes(?) |
Is the error message misleading? vet: typecheck failures anyway, regardless of where the origin of this change is, the changed behavior should be documented clearly. It's a newly observed behavior from 1.11. |
I think it's correct, but too brief. Maybe it should be changed to something like "vet: the package did not typecheck"
Agree, but what changed? vet typechecks since 1.10, and test runs vet since 1.10. Why is this failing now on tip and not on 1.10? |
Ah, my bad. This is false:
it was put in, disabled to fix a go/types issue, and then re-enabled again during the 1.11 cycle, here: https://go-review.googlesource.com/c/go/+/108555 So it should be documented. |
As discussed in golang/go#26109, vet typecheck is enabled in go1.11 and the command_test.go can't be compiled any more with go1.11 due to the unread variables in the command_test.go. Instead of removing the unused variables, this CL reads the variables and compares the values against the current behavior so when the related issue is fixed, this test can be updated accordingly.
Change https://golang.org/cl/121455 mentions this issue: |
As discussed in golang/go#26109, vet typecheck is enabled in go1.11 and the command_test.go can't be compiled any more with go1.11 due to the unread variables in the command_test.go. Instead of removing the unused variables, this CL reads the variables and compares the values against the current behavior so when the related issue is fixed, this test can be updated accordingly.
Sorry, I'm experiencing this error and I'd like to know what I'm supposed to be doing instead of
Why is this considered a failure? |
Where? When?
Use the
Because unused variables are not allowed in Go (at least in |
@ALTree I'm experiencing it with the same closure usecase as you posted. By my reading, |
A value that is only ever written to but never read from is effectively unused. go/types (which vet uses) is more strict about this than the compiler. |
vet check seems to be included in gc by default but not documented in go1.11 release note yet (sorry, I didn't search enough to find related issue/proposal/change to link yet).
This behavior change resulted in build-failures for codes that don't pass vet currently and could be misunderstood as a regression in go1.11. For example, with go1.11 (or tip), go test on
github.com/spf13/cobra will fail due to failure to pass vet check.
BTW, the vet error message is confusing because the parentPersPreArgs and parentPersPostArgs in the test are 'used' (literally). But for the purpose of vet check, the vars are 'not used' because they are never read.
The text was updated successfully, but these errors were encountered: