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

Open
adonovan opened this issue Nov 25, 2024 · 2 comments
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
Contributor

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

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