Compiling
package p
type SliceConstraint[T any] interface {
[]T
}
func Map[S SliceConstraint[E], E any](s S, f func(E) E) S {
return s
}
type MySlice []int
func f(s MySlice) {
Map[MySlice, int](s, nil)
}
produces
x.go:14:19: MySlice does not satisfy SliceConstraint[E]
It's hard to see what the error is. It should have been
type SliceConstraint[T any] interface {
~[]T // <<< need ~ here!
}
We need to produce a better error message in cases like these. This will frustrate a lot of users.
cc: @findleyr
Compiling
produces
It's hard to see what the error is. It should have been
We need to produce a better error message in cases like these. This will frustrate a lot of users.
cc: @findleyr