You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I frequently use goto continue with a ::continue:: label as a proxy for Lua's lack of a first-class continue keyword and I often find myself getting bit by jumping over a local variable declaration that doesn't go out of scope; easy enough to fix by introducing do ... end blocks.
Could be a nice warning/lint/error to be able to see via Luacheck.
Here's an extremely simple self contained example:
🐧 ❯ cat init.lua
function bad_goto_loop()
while true do
goto continue
local some_var = "foo"
::continue::
print("loop end, starting again")
end
end
🐧 ❯ lua init.lua
lua: init.lua:6: <goto continue> at line 3 jumps into the scope of local 'some_var'
The text was updated successfully, but these errors were encountered:
The Lua interpreter seems to find this error even without executing it.
Luacheck already finds and throws two errors related to this code. The problem would be much more interesting if you had an MWE that showed off this problem without also triggering other lint issues.
I frequently use
goto continue
with a::continue::
label as a proxy for Lua's lack of a first-classcontinue
keyword and I often find myself getting bit by jumping over a local variable declaration that doesn't go out of scope; easy enough to fix by introducingdo ... end
blocks.Could be a nice warning/lint/error to be able to see via Luacheck.
Here's an extremely simple self contained example:
The text was updated successfully, but these errors were encountered: