Closed
Description
I'm not sure if this is a bug or a feature.
In CL 177601, it was explicitly noted that %w
verbs would not match interface{}
.
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 implement error
.
Either one of these outcomes is reasonable to me:
- the type system allows us to express 'implements' relationships between interfaces, so it is likely a user error if the argument type for
%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). - ...but on the other hand we have very low tolerance for false positives in vet. If reasonable user code is generating a false positive, it should be fixed.
I just wanted to flag this inconsistency. What is correct here?
(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).