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

x/tools/gopls: rename of receiver var gives spurious shadowing error #60752

Closed
adonovan opened this issue Jun 12, 2023 · 6 comments
Closed

x/tools/gopls: rename of receiver var gives spurious shadowing error #60752

adonovan opened this issue Jun 12, 2023 · 6 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

There's a bug in the shadowing logic of rename w.r.t. receivers:

type foo int

func (f foo) f() {} // rename f to foo:

error: renaming this var "f" to "foo" [the receiver variable name]
would shadow this reference [the receiver type name]
to the type declared here [above]

The renaming is actually safe, since the receiver is resolved in the package scope.

@adonovan adonovan self-assigned this Jun 12, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 12, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2023
@findleyr
Copy link
Contributor

This seems like something that can wait for v0.13.0, so moving to that milestone.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.13.0 Jun 12, 2023
@gopherbot
Copy link

Change https://go.dev/cl/509560 mentions this issue: gopls/internal/lsp/source: fix rename spurious receiver shadowing error

@adonovan
Copy link
Member Author

adonovan commented Jul 14, 2023

While working on https://go.dev/cl/509875 I temporarily deluded myself that these were two aspects of the same bug. They were not, but I had to do most of the work of fixing this one to figure it out. Bumping this back to v0.12. ;-)

@adonovan
Copy link
Member Author

(Reopened as fix was reverted.)

@gopherbot
Copy link

Change https://go.dev/cl/543720 mentions this issue: gopls/internal/lsp/source: fix rename spurious shadowing error

gopherbot pushed a commit to golang/tools that referenced this issue Dec 4, 2023
(Second attempt at CL 509560, rolled back in a5e8bb0, because
it broke tests that had been added since this CL was tested.
It was the wrong fix; the right fix is CL 544035 to go/types.)

This change documents and tests the go1.22-only fix for a bug
in the rename lexical shadowing check due to a bug in go/types.

Updates golang/go#60752
Updates golang/go#64292

Change-Id: I9bc96807fdd2ee5c4712268de16cf2d04513773a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/543720
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
@adonovan
Copy link
Member Author

adonovan commented Dec 4, 2023

Fixed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants