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

cmd/compile: puzzling "does not satisfy comparable" error message #49112

Closed
ALTree opened this issue Oct 22, 2021 · 5 comments
Closed

cmd/compile: puzzling "does not satisfy comparable" error message #49112

ALTree opened this issue Oct 22, 2021 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Oct 22, 2021

$ gotip version
go version devel go1.18-9ff91b9098 Fri Oct 22 00:57:18 2021 +0000 windows/amd64
package main

type I interface {
	int
}

func f[G I](g G) {
	println(g)
}

func main() {
	var v1 float64
	var v2 []int
	f(v1)
	f(v2)
}

Building prints:

$ gotip build test.go
# command-line-arguments
.\test.go:14:3: float64 does not satisfy I
.\test.go:15:3: []int does not satisfy comparable

The error message for f(v1) makes sense:

float64 does not satisfy I

but the one for f(v2) is puzzling:

[]int does not satisfy comparable

It mentions the predeclared constraint comparable, but comparable has nothing to do with I. Why?

cc @griesemer @findleyr

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 22, 2021
@ALTree ALTree added this to the Go1.18 milestone Oct 22, 2021
@DiscoRiver
Copy link

DiscoRiver commented Oct 22, 2021

Error message needs updating?

return errorf("%s does not satisfy comparable", targ)

@findleyr
Copy link
Contributor

@DiscoRiver yes, that looks right. We're checking comparable as a precondition (since the type set {int} is comparable), but the error message is misleading.

Thanks for the report.

@findleyr findleyr added okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 release-blocker labels Oct 22, 2021
@griesemer griesemer self-assigned this Oct 22, 2021
@cherrymui cherrymui removed the okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 label Dec 14, 2021
@cherrymui
Copy link
Member

Any update on this? Thanks. (checking in as this is a release blocker.)

@griesemer
Copy link
Contributor

I will start looking at this later today.

@gopherbot
Copy link

Change https://golang.org/cl/372594 mentions this issue: cmd/compile/internal/types2: delay "does not satisfy comparable" error until needed

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants