-
Notifications
You must be signed in to change notification settings - Fork 18k
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
go/types: Cannot return T
from method receiving Generic[T]
#57182
Comments
this doesn't do what you think it does. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
|
I vaguely recall there was a suggested vet check for this. |
the check was deemed premature at the time #48123 |
What version of Go are you using (
go version
)?Go Playground with Go 1.18, 1.19, and dev branch.
Does this issue reproduce with the latest release?
Yes.
What did you do?
See https://go.dev/play/p/fCO1GDA_oZj?v=gotip for an example.
I defined a generic type, e. g.:
Then I wanted to add a method receiving an instantiation of this generic type and returning
T
, e. g.:What did you expect to see?
I would expect the program to build without errors.
What did you see instead?
Adding the method leads to an error when building the program:
The program only builds if the return type of the method is different from
T
.The text was updated successfully, but these errors were encountered: