Skip to content

remove_unused_variable incorrect behaviorΒ #209

@otagrua

Description

@otagrua

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions