Closed
Description
This code:
package main
type pointerToT[T any, PT pointerToT[T, PT]] interface{
*T
}
func F[T any, PT pointerToT[T, PT]](n, nn PT) {
}
compiles just fine, however adding a new function definition, calling F:
package main
type pointerToT[T any, PT pointerToT[T, PT]] interface{
*T
}
func F[T any, PT pointerToT[T, PT]](n, nn PT) {
}
func WrapF[A any, PA pointerToT[A, PA]](n, nn PA) {
F(n, nn)
}
Causes the error: ./buggy.go:7:15: PT does not match *T
on the line declaring F
. It's weird that declaring a function would cause a different function to no longer typecheck correctly, I think this error was meant to be reported on the call to F.
It's also unclear what the problem is, shouldn't the type inference work correctly? Manually instantiating F as F[A, PA](n, nn)
makes the error go away.