Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types, types2: misleading error message when type param is not comparable #48712

Open
findleyr opened this issue Oct 1, 2021 · 0 comments
Open
Assignees
Milestone

Comments

@findleyr
Copy link
Contributor

@findleyr findleyr commented Oct 1, 2021

Consider the following invalid program:

package p

func f[T any](t T) func(interface{}) bool {
	return func(x interface{}) bool {
		return x == t
	}
}

The type checker produces the error cannot compare x == t (operator == not defined for interface{}), but that's not accurate. The real problem is that T is not comparable.

CC @griesemer

@findleyr findleyr added this to the Go1.18 milestone Oct 1, 2021
@griesemer griesemer self-assigned this Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants