-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ignore "local variable is never mutated" error if ignoring with "_ = myvar" #20584
Comments
Not a bug. The intended way to discard |
(as pointed out above) The current compile error has a |
Even in prototyping, what is your use case for this? |
The use case is usually prototyping new behaviour within a game loop, so putting a new variable at the top of the loop: var some_variable_we_want_to_retain_across_frames: [256]u8 | i32 // could be a buffer, an int, a struct, whatever
while (!has_game_exited) { Then deeper within this large game-loop, hundreds of lines below, I'm making this variable be used for something.
With Zig, the unused variable rule was initially not a big issue for me because ZLS could auto-generate the unused logic with |
I would suggest creating an issue for an autofix |
Zig Version
0.13.0
Steps to Reproduce and Observed Output
Expected Output
If I'm purposefully ignoring using a variable for now, I don't want it to throw an error as I then need to change it to
const
, then remove the ignore statement, then revert fromconst
tovar
while I'm prototyping things.The text was updated successfully, but these errors were encountered: