cmd/compile: type parameter involving constraint with channels seems like it should be inferrable #69153
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
TypeInference
Issue is related to generic type inference
Milestone
Go version
go1.23 and go tip
Output of
go env
in your module/workspace:What did you do?
https://go.dev/play/p/-psvliJDE_j
I want to write a small utility that takes a specific action that is determined by a channel's length and/or capacity. In this codebase, there are a general mix of directional and bidirectional channels. I thought I would be able to write a constraint such that my helper can accept a channel of any directionality. And I can indeed write that constraint, but when I call a function with that constraint, I have to provide the channel's element type as a type parameter in order to get the program to compile.
I am surprised that I have to provide the channel's element type, but maybe I am missing something about constraints or generics.
What did you see happen?
What did you expect to see?
I expected that
printCap(ch)
would compile; that I would not have to writeprintCap[int](ch)
.I tried searching the issues for variations of "constraints", "channels", and "direction" or "directionality" but I was not able to find any issues that looked similar.
The text was updated successfully, but these errors were encountered: