seaofvoices / darklua

A command line tool that transforms Lua code
https://darklua.com/
MIT License
71 stars 9 forks source link

`remove_unused_variable` trips up on repeat ... until ... when variable defined in loop body is referenced in condition #186

Closed sircfenner closed 3 months ago

sircfenner commented 4 months ago

Current behavior, when running darklua process with remove_unused_variable as the only rule:

repeat
    local x = true
until x

generates:

repeat
until x

Expected behavior is that variables defined in the loop body are considered "used" if referenced in the condition. Tested on darklua version 0.13.0.

jeparlefrancais commented 4 months ago

Thank you for the report, I'll add this test case once I fix it. I really messed up that rule apparently 😅

Related to #182