You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only one found solution to #41695 (and #40010 by extension) which is actually the only one safe is just to allow the builtin copy function from a slice of undirected channels to a slice of directed channels.
package main
funcmain() {
src:= []chanint{make(chanint)}
vardest []<-chanint_=copy(dest, src)
}
We got the following error: arguments to copy have different element types: []<-chan int and []chan int.
This proposal should be more general and relaxed to the cases in which implicit conversions are allowed from source element type to destination element type. For example:
package main
typeT*intfuncmain() {
vara [100]Tvarb=make([]*int, len(a))
copy(b, a[:]) // error: arguments to copy have different element types: []*int and []T
}
package main
typeT*intfuncmain() {
vara [2]Tvarb=make([]*int, len(a))
b=append(b[:0], a[0], a[1]) // okb=append(b[:0], a[:]...) // error: cannot use a[:] (type []T) as type []*int in append
}
Hello,
The only one found solution to #41695 (and #40010 by extension) which is actually the only one safe is just to allow the builtin copy function from a slice of undirected channels to a slice of directed channels.
We got the following error:
arguments to copy have different element types: []<-chan int and []chan int
.Today, the only one solution is :
The idea came from @bcmills: #41695 (comment)
The text was updated successfully, but these errors were encountered: