Consider the following 3-files program:
go.mod:
module example.com/mod
go 1.18
a/a.go
package a
type I interface {
struct{ i int }
}
func F[T I]() {}
test.go
package main
import "example.com/mod/a"
func main() {
a.F[struct{ i int }]()
}
With go1.18 and tip, the program does not compile:
$ go build
# example.com/mod
.\test.go:6:6: struct{i int} does not implement a.I
playground link: https://go.dev/play/p/yvRVxYbdkpK
To to me it looks like it should(?). The same constraint and function work fine when they're part of the main package. Am I missing something?
EDIT: I had the wrong mental model, it's correct that this doesn't work but the error message is slightly confusing. See below.
cc @findleyr @griesemer @mdempsky