proposal: spec: permit unused type parameters to not be inferred #57620
Labels
generics
Issue is related to generics
Proposal
TypeInference
Issue is related to generic type inference
Milestone
I was recently trying roughly the following segment of code expecting it to work:
https://go.dev/play/p/yTVhxJ82pMR
Lines 47 and 48 are commented out; lines 53 and 54 are what I would have to do if I want to use
First
. If possible, it'd be great to not have to fully specify the types and instead rely entirely on type inference.Speaking as a complete newbie / uninformed person here, I'd think the algorithm would be:
For slices,
For maps,
I recognize this is a naive and simple proposal that absolutely does not capture the underlying complexity. Go also currently requires all types to be specified, and in the slice case, there is no
K
; this requirement would need to be relaxed in the type union case.The closest related issue I see is #56975, but that is different because the proposal is specific to functions and is actually not about a union.
The text was updated successfully, but these errors were encountered: