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

go/types: spurious diagnostics for untyped shift operands with GoVersion < go1.13 [1.18 backport] #52032

Closed
gopherbot opened this issue Mar 30, 2022 · 4 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Milestone

Comments

@gopherbot
Copy link

@findleyr requested issue #52031 to be considered for backport to the next 1.18 minor release.

@gopherbot please backport to 1.18, this is a newly visible bug with no workaround.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Mar 30, 2022
@gopherbot gopherbot added this to the Go1.18.1 milestone Mar 30, 2022
@heschi
Copy link
Contributor

heschi commented Mar 30, 2022

Note that the next minor release is scheduled for next week; if this fix is intended to land for that release it should be prepared soon.

@gopherbot
Copy link
Author

Change https://go.dev/cl/397680 mentions this issue: [release-branch.go1.18] go/types: don't report errors for untyped int shifts on Go < 1.13

@cherrymui
Copy link
Member

Approved for backport. This affects users with a go version <1.13 set in go.mod file.

@cherrymui cherrymui added NeedsFix The path to resolution is known, but the work has not been done. CherryPickApproved Used during the release process for point releases and removed CherryPickCandidate Used during the release process for point releases NeedsFix The path to resolution is known, but the work has not been done. labels Apr 6, 2022
@gopherbot
Copy link
Author

Closed by merging 9535031 to release-branch.go1.18.

gopherbot pushed a commit that referenced this issue Apr 6, 2022
… shifts on Go < 1.13

CL 337529 introduced upfront type-checking of constant shift operands,
to avoid converting their type to uint (per the spec). However, it
had an oversight in that the checks intended for non-constant operands
still ran after the explicit checking of constant operands. As a
result, there are at least two bugs:
 - When GoVersion is < 1.13, we report spurious errors for untyped
   constant shift operands.
 - When the operand is an untyped float constant, we still convert to
   uint (this was a known bug reported in #47410).

Looking at this now, it seems clear that we can avoid both of these bugs
by simply not running the additional checks in the case of a constant
operand. However, this should be considered with some care, as shifts
are notoriously tricky.

While cherry-picking, the new test file is updated to use the go1_12
package name, following our convention for specifying language version
in the release branch.

Fixes #52032

Change-Id: Ia489cc5470b92a8187d3de0423d05b309daf47bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/396775
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 8a816d5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397680
@golang golang locked and limited conversation to collaborators Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants