Skip to content

go/types, cmd/compile/internal/types2: type inference limitation leads to incorrect result for directed channel type constraint #65202

Description

@leaxoy

Proposal Details

Think such code:
can be found here: https://go.dev/play/p/qNBK9KjxqrW

func Chan[E any, C ~<-chan E](c C) {}

func x() {
    c := make(chan int)
    Chan(c)
}

then Chan(c) produce chan int does not satisfy ~<-chan int (chan int missing in ~<-chan int)

In my opinion, this is a flaw in generic design that should be supported

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.TypeInferenceIssue is related to generic type inferencegenericsIssue is related to generics

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions