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 #52031

Closed
findleyr opened this issue Mar 30, 2022 · 3 comments
Milestone

Comments

@findleyr
Copy link
Contributor

As reported in #51947 (comment), when using the new types.Config.GoVersion field with a Go version < 1.13, go/types produces inaccurate errors for untyped shift operands, as in the following code from go-cmp:

type resultFlags uint

const (
	_ resultFlags = (1 << iota) / 2

	reportEqual
	reportUnequal
	reportByIgnore
	reportByMethod
	reportByFunc
	reportByCycle
)

This is a new regression, only reachable via use of the GoVersion field, but it newly affects gopls because we are now setting the GoVersion field based on go.mod, and go-cmp still has go1.11 in their go.mod.

The fix looks straightforward but shifts are notoriously tricky and have been a source of a significant number of bugs in the past. Nevertheless, we should endeavor to fix this regression for Go 1.18.1.

CC @griesemer

@findleyr findleyr added this to the Go1.18.1 milestone Mar 30, 2022
@findleyr
Copy link
Contributor Author

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

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #52032 (for 1.18).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/396775 mentions this issue: go/types: don't report errors for untyped int shifts on Go < 1.13

@cherrymui cherrymui modified the milestones: Go1.18.1, Go1.19 Apr 4, 2022
@golang golang locked and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants