Skip to content

cmd/compile: close allows type parameterized channels of different element types #74034

Open
@zigo101

Description

@zigo101

Go version

tip

Output of go env in your module/workspace:

.

What did you do?

https://tip.golang.org/ref/spec#Close

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.

What did you see happen?

The code compiles:

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

What did you expect to see?

I tend to think this is a spec bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions