Skip to content

cmd/compile: incorrect type set intersection computation #57486

@zigo101

Description

@zigo101

What version of Go are you using (go version)?

$ go version
go version go1.19.4 linux/amd64

Does this issue reproduce with the latest release?

Yes, also for tip.

What did you do?

package main

func main() {}

type C1 interface {
	comparable
}

type C2 interface {
	comparable
	[2]any | int
}

func G1[T C1](t T) {}
func G2[T C2](t T) {}

func F1[V [2]any](v V) {
	_ = G1[V] // error: V does not implement comparable
}

func F2[V [2]any](v V) {
	_ = G2[V] // okay (but should not?)
}

What did you expect to see?

Both F1 and F2 fail to compile.

What did you see instead?

F2 compiles okay.

My understanding is that the type set of C2 only contains int, because [2]any is not strictly comparable, though my understanding might be wrong.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.release-blocker

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions