-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/compile: type inference fails for unused type in generic type alias #70948
Comments
CC @griesemer |
This may not be working as expected, but it is working as intended: The type parameter type A[V any] = struct{}
func f[V any](A[V]) {}
func main() {
f[string](A[int]{})
} This code works even though the explicit type argument to Generally, type inference must fail in cases where there is more than type possible because it cannot prove that whatever type it selected is the right one. Only the programmer can answer that question. As soon as type A[V any] = struct{ _ V }
func f[V any](A[V]) {}
func main() {
f(A[int]{})
} compiles and runs as expected. |
Go version
go version devel go1.24-669d87a Thu Dec 19 19:19:59 2024 -0800 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
Compilation failure.
What did you expect to see?
Successful compilation, even tho
type A[V any] = struct{}
doesn't make much sense.Notes:
The text was updated successfully, but these errors were encountered: