go/types: type parameter objects are not consistent across method signatures #48795
Labels
FrozenDueToAge
generics
Issue is related to generics
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
The type parameter in method signatures for a generic type should refer to the declared type parameter in the type declaration.
What did you see instead?
The go/types package yields a different
types.TypeParam
for thePrint
method's type parameter (T₂
) vs the type declaration's (T₁
). This makes it difficult for tooling to recognize that they are the same type parameter with the same constraints without extra bookkeeping.The compiler also allows for an arbitrary new identifier referring to the generic type in the receiver (as in the
X₃
type parameter forF
). This seems like syntax that should be disallowed per Go's usual styling.The text was updated successfully, but these errors were encountered: