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: refactor.extract.variable on RHS of const declaration produces invalid code #70562

Closed
adonovan opened this issue Nov 25, 2024 · 4 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. help wanted 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

Before:

const K = "" // apply refactor.extract.variable on ""

After:

var x = ""
const K = x // error: variable x is not constant
@gabyhelp
Copy link

@adonovan adonovan added gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools help wanted labels Nov 25, 2024
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 25, 2024
@gopherbot gopherbot added this to the Unreleased milestone Nov 25, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/backlog Nov 26, 2024
@findleyr
Copy link
Member

We should offer refactor.extract.constant (but not extract.variable) in this case.

@adonovan
Copy link
Member Author

adonovan commented Dec 3, 2024

See #37170 for refactor.extract.constant.

@adonovan
Copy link
Member Author

adonovan commented Dec 4, 2024

Fixed by https://go.dev/cl/633257.

@adonovan adonovan closed this as completed Dec 4, 2024
@findleyr findleyr modified the milestones: gopls/backlog, gopls/v0.17.0 Dec 4, 2024
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. help wanted 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

4 participants