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

remove_unused_variable incorrect behavior #209

Open
otagrua opened this issue Sep 1, 2024 · 0 comments
Open

remove_unused_variable incorrect behavior #209

otagrua opened this issue Sep 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@otagrua
Copy link

otagrua commented Sep 1, 2024

remove_unused_variable incorrectly removes unassigned local variables in grouped local assignments after a function call and assigned variable.

Reproduction

a.luau:

local c = 0;
(function()
    local a, b, c = (function()end)(), 0;
    c = 1;
end)();
assert(c == 0);

.darklua.json:

{
    "rules": [
        "remove_unused_variable"
    ]
}
darklua process a.luau out.luau --verbose
 INFO > using configuration file `.darklua.json`
 INFO > successfully processed `a.luau`
 INFO > executed work in 1.2508ms
successfully processed 1 file (in 2.049ms)
darklua --version
darklua 0.13.1

out.luau:

local c = 0;
(function()
local a=(function()end)();
    c = 1;
end)();
assert(c == 0);

This output is incorrect. When combined with group_local_assignment and rename_variables, this bug is more likely to break scripts.

@jeparlefrancais jeparlefrancais added the bug Something isn't working label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants