-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version devel +c875503cf7 Sun Jun 28 03:14:10 2020 +0000 linux/amd64
Does this issue reproduce with the latest release?
It does on go1.14, haven't checked the most recent minor release.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GOARCH="amd64" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux"(redacted some stuff)
What did you do?
https://play.golang.org/p/YZG9p_qVnyC
package main
import(
"reflect"
)
type StandsOut int // so we can grep for it
func main() {
var a chan (<-chan StandsOut)
var b chan<- (chan StandsOut)
var c <-chan (<-chan StandsOut)
ta := reflect.ChanOf(
reflect.BothDir, reflect.ChanOf(
reflect.RecvDir, reflect.TypeOf(StandsOut(0)),
),
)
tb := reflect.ChanOf(
reflect.SendDir, reflect.ChanOf(
reflect.BothDir, reflect.TypeOf(StandsOut(0)),
),
)
tc := reflect.ChanOf(
reflect.RecvDir, reflect.ChanOf(
reflect.RecvDir, reflect.TypeOf(StandsOut(0)),
),
)
println("ta == reflect.TypeOf(a)", ta == reflect.TypeOf(a))
println("tb == reflect.TypeOf(b)", tb == reflect.TypeOf(b))
println("tc == reflect.TypeOf(c)", tc == reflect.TypeOf(c))
}What did you expect to see?
ta == reflect.TypeOf(a) true
tb == reflect.TypeOf(b) true
tc == reflect.TypeOf(c) true
What did you see instead?
ta == reflect.TypeOf(a) false
tb == reflect.TypeOf(b) true
tc == reflect.TypeOf(c) true
This bug appears to be known but I couldn't find a corresponding github issue.
When grepping the resulting binary, the type of a in the above program appears to be recorded as chan (<-chan main.StandsOut), so the solution might be as simple as building additional parentheses around typ.string() in the implementation of reflect.ChanOf whenever the outer chan is BothDir and the inner chan is RecvDir.
I'll try to fix it.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.