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

Autofix on mutating constant #1621

Closed
DivergentClouds opened this issue Nov 23, 2023 · 4 comments
Closed

Autofix on mutating constant #1621

DivergentClouds opened this issue Nov 23, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@DivergentClouds
Copy link

Due to #1607 if you write something like var foo: usize = 0 and then you run autofix (my autofix runs on save) it will turn into const foo: usize = 0 and if you mutate it later by adding foo += 1 for example, you will get an error for attempting to assign to a constant.

@DivergentClouds DivergentClouds added the enhancement New feature or request label Nov 23, 2023
@leecannon
Copy link
Member

I don't think auto const -> var fits zig.

@nektro
Copy link
Contributor

nektro commented Nov 23, 2023

this is zls not zig

but if that's still your opinion, then the var->const autofix shouldn't be in zls either

@DivergentClouds
Copy link
Author

DivergentClouds commented Nov 23, 2023

I think the zls autofix should change how the var to const works then to add a _ = &foo instead of making it const. I don't want to have to fight with the language server when I just want to save in middle of writing my code.

@Techatrix
Copy link
Member

fixed by #1652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants