Closed
Description
When for-loop is located at root level of the file, it's variables from initializer are global
But when I add any level (empty brackets or a function) they're being local
// Uncomment brackets to make `val` local
// {
for (let val = 0; val < 2; ++val) print(val);
print('For loop end')
// Should be nil, but indeed it prints "2"
print(val)
// }
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
do
val = 0 -- here "local" keyword missing is
while val < 2 do
print(val)
val = val + 1
end
end
print("For loop end")
print(val)