-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: switching over channel value incorrectly does not match when the direction is narrower in the case #67190
Comments
cc @golang/compiler |
The behavior changed from 1.19 to 1.20. |
I'll send a fix |
Ok so the bug, this code assumes that the type of the case can't be assigned to the type of the tag it needs to compared with ch1 := make(chan struct{})
var ch2 <-chan struct{} = ch1
fmt.Println("Equal:", ch1 == ch2)
fmt.Println("any Equal:", any(ch1) == any(ch2)) prints |
It looks like the any compare behavior is correct:
so TIL https://gophers.slack.com/archives/C1C1YSQBT/p1714960380488909 |
Possibly duplicate of #44051 |
I don't think so, here I'm assuming the behavior seen in #44051 is correct and not a bug yet this is still broken. |
Change https://go.dev/cl/583395 mentions this issue: |
Needs more changes in |
Change https://go.dev/cl/594575 mentions this issue: |
Change https://go.dev/cl/596575 mentions this issue: |
CL 418101 changes Unified IR writer to force mixed tag/case to have common type, emitting the implicit conversion if any of the case values are not assignable to the tag value's type. However, the Go spec definition of equality is non-transitive for channels stored in interfaces, causing incorrect behavior with channel values comparison. To fix it, don't emit the implicit conversions if tag type is channel. Fixes golang#67190 Change-Id: I9a29d9ce3c7978f0689e9502ba6f15660c763d16 Reviewed-on: https://go-review.googlesource.com/c/go/+/594575 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
Go version
go version devel go1.23-619b419a4b Sun May 5 00:26:04 2024 +0000 linux/amd64
Output of
go env
in your module/workspace:What did you do?
@LeaBit
on discord gophers report this behavior:What did you see happen?
What did you expect to see?
The text was updated successfully, but these errors were encountered: