-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.release-blocker
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version devel go1.18-eaf0405 Wed Feb 16 21:34:51 2022 +0000 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
https://go.dev/play/p/PzbJGM7V9dn?v=gotip
package main
type RC[RG any] interface {
~[]RG
}
type Fn[RCT RC[RG], RG any] func(RCT)
type FFn[RCT RC[RG], RG any] func() Fn[RCT]
type F[RCT RC[RG], RG any] interface {
Fn() Fn[RCT]
}
type concreteF[RCT RC[RG], RG any] struct {
- makeFn FFn[RCT]
+ makeFn FFn[RCT, RG]
}
func (c *concreteF[RCT, RG]) Fn() Fn[RCT] {
return c.makeFn()
}
func main() {}
What did you expect to see?
Nothing.
What did you see instead?
./prog.go:20:9: invalid operation: cannot call non-function c.makeFn (variable with invalid type)
If I change the line from the red version to the green version (adding the explicit type), then the compilation error disappears. I expected the compiler to figure out RG
since it was part of the definition of RCT
.
If type inference isn't able to figure this out, then it would be good to fix the compiler error to be less confusing. makeFn
is a function, the error is actually that the compiler can't infer how to instantiate it.
Notes
- This isn't actually quite the error I originally ran into, but it's similar enough that it's likely related
- I ran into cmd/compile: internal compiler error: invalid memory address or nil pointer dereference #51232 while trying to distill this, if that's helpful
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.release-blocker