Skip to content

proposal: allow passing type parameterized channels of different element types to "close". #74034

Open
@zigo101

Description

@zigo101

The spec says:

If the type of the argument to close is a type parameter, all types in its type set must be channels with the same element type.

But the code compiles (since 1.18):

func dig[T ~chan int | ~chan bool | ~chan<- string](x T) {
	close(x)
}

So maybe it is a good idea to just remove the about quoted line from spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LanguageProposalIssues describing a requested change to the Go language specification.Proposalcompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions