Skip to content
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: backward incompatible change in Go 1.21 type inference with channels [1.21 backport] #62205

Closed
gopherbot opened this issue Aug 22, 2023 · 6 comments
Assignees
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@gopherbot
Copy link

@griesemer requested issue #62157 to be considered for backport to the next 1.21 minor release.

@gopherbot please consider this for backport to 1.21, this is partly a regression and partly a pre-existing bug.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Aug 22, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 22, 2023
@gopherbot gopherbot added this to the Go1.21.1 milestone Aug 22, 2023
@griesemer griesemer self-assigned this Aug 22, 2023
@cagedmantis cagedmantis added the CherryPickApproved Used during the release process for point releases label Aug 23, 2023
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Aug 23, 2023
@cagedmantis
Copy link
Contributor

Approved as this was a regression.

@joedian
Copy link

joedian commented Aug 28, 2023

@griesemer can the create the cherrypick cl please?

@griesemer
Copy link
Contributor

Sorry, we don't have a correct fix for this yet. This turns out to be more tricky than anticipated.

@gopherbot
Copy link
Author

Change https://go.dev/cl/524256 mentions this issue: [release-branch.go1.21] go/types, types2: remove order dependency in inference involving channels

@griesemer
Copy link
Contributor

@joedian Once reviewed, this is ready to go.

gopherbot pushed a commit that referenced this issue Aug 30, 2023
…inference involving channels

In inexact unification, when a named type matches against an inferred
unnamed type, we change the previously inferred type to the named type.
This preserves the type name and assignability.

We have to do the same thing when encountering a directional channel:
a bidirectional channel can always be assigned to a directional channel
but not the other way around. Thus, if we see a directional channel, we
must choose the directional channel.

This CL extends the previously existing logic for named types to
directional channels and also makes the code conditional on inexact
unification. The latter is an optimization - if unification is exact,
type differences don't exist and updating an already inferred type has
no effect.

Fixes #62205.

Change-Id: I807e3b9f9ab363f9ed848bdb18b2577b1d680ea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/524256
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
@gopherbot
Copy link
Author

Closed by merging b120517 to release-branch.go1.21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

4 participants