$ 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
Building prints:
The error message for
f(v1)makes sense:but the one for
f(v2)is puzzling:It mentions the predeclared constraint
comparable, butcomparablehas nothing to do withI. Why?cc @griesemer @findleyr