-
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: printf analysis no longer flags interfaces that don't implement error #48931
Comments
My opinion in CL 177601 was that I couldn't think of any real-world cases where you would want to use the In the time since the check being added, I don't think I've ever heard of a I think |
To be clear this is not currently the case, as of CL 217180: Vet only reported arguments of interface type in Go 1.14. Per your reasoning, this is a regression. I agree with your logic, but thought perhaps we had encountered reasonable false positives. @kortschak, is this consistent with your expectation? Do you still think that we should exempt arguments of interface type from this check? Should |
I think that it's reasonable to make |
Change https://golang.org/cl/355730 mentions this issue: |
Bit late to the party. I am having a hard time recalling a real false positive, and I am struggling to think of a realistic false positive. A piece of support for being strict (/ suggesting
|
I'm not sure if this is a bug or a feature.
In CL 177601, it was explicitly noted that
%w
verbs would not matchinterface{}
.Subsequently, in CL 217180, printf analyzer logic was changed to account for the fact that any argument of interface type could be a
fmt.Formatter
. More context in #36564. As a side-effect, we no longer report diagnostics if arguments for%w
of interface type do not implementerror
.Either one of these outcomes is reasonable to me:
%w
does not implement error (the same is not true of, say,%d
, as we can't currently express that an interface's dynamic type is integral).I just wanted to flag this inconsistency. What is correct here?
CC @neild @timothy-king
(FWIW, I'm interested in this as a matter of precedent, as I'm trying to figure out what to do with type parameters, where users may express structural restrictions on the underlying of a type parameter).
The text was updated successfully, but these errors were encountered: