It looks the generic type argument must share the underlying type of a type
in the constraint type list.
But the following code also fails to compile, bug?
package main
type Int interface {
type int
}
func Foo(type T Int) ([]T) {} // undefined: MyInt
func main() {
type MyInt int
Foo([]MyInt(nil))
}
On Thursday, June 18, 2020 at 7:22:51 AM UTC-4, T L wrote:
>
> Another question, how to make the following code compile:
>
> package main
>
> type IntSlice interface {
> type []int
> }
>
> func Foo(type T IntSlice) (T) {}
>
> func main() {
> type MyInt int
> Foo([]int(nil))
> Foo([]MyInt(nil)) // []MyInt does not satisfy IntSlice ([]MyInt not
> found in []int)
> }
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/c5f5f3b8-b609-4795-9f27-806409decd5ao%40googlegroups.com.