cmd/compile: spurious "cannot infer T" type error #66842
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
generics
Issue is related to generics
TypeInference
Issue is related to generic type inference
Milestone
While working on https://go.dev/cl/578675, I noticed that some explicit type arguments were required in order to pacify the compiler---and also gopls' diagnostics, which run the go/types type checker. (Adding the explicit type arguments caused gopls' infertypeargs analyzer to tell me they were redundant, which I think they should be, but that's not what either go/types or go/types2 thinks.)
GOROOT @ 7418d41, x/tools @ cb134f5
Now apply this patch, which removes type arguments from the call to
typesSeqToSlice
:typesSeqToSlice is defined thus:
Notably, its type parameters constrain only the results, not the arguments.
Strangely, the offending statement compiles just fine in the playground so I wonder whether the nested function context is confusing the type inference algorithm.
The text was updated successfully, but these errors were encountered: