mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
declare the variables introduced by for loop into scope #44
This commit is contained in:
parent
43c1e0a4fb
commit
98ebb97b16
@ -157,6 +157,9 @@ line_compile = {
|
||||
}), " do")
|
||||
do
|
||||
local _with_0 = self:block(loop)
|
||||
_with_0:declare({
|
||||
name
|
||||
})
|
||||
_with_0:stms(block)
|
||||
return _with_0
|
||||
end
|
||||
@ -195,6 +198,7 @@ line_compile = {
|
||||
end
|
||||
do
|
||||
local _with_0 = self:block(loop)
|
||||
_with_0:declare(names)
|
||||
_with_0:stms(block)
|
||||
return _with_0
|
||||
end
|
||||
|
@ -91,6 +91,7 @@ line_compile =
|
||||
_, name, bounds, block = unpack node
|
||||
loop = @line "for ", @name(name), " = ", @value({"explist", unpack bounds}), " do"
|
||||
with @block loop
|
||||
\declare {name}
|
||||
\stms block
|
||||
|
||||
-- for x in y ...
|
||||
@ -106,6 +107,7 @@ line_compile =
|
||||
\append " do"
|
||||
|
||||
with @block loop
|
||||
\declare names
|
||||
\stms block
|
||||
|
||||
export: (node) =>
|
||||
|
@ -197,8 +197,8 @@ local hello = (function()
|
||||
for _index_0 = 1, #_list_1 do
|
||||
x = _list_1[_index_0]
|
||||
local _list_2 = items
|
||||
for _index_0 = 1, #_list_2 do
|
||||
local y = _list_2[_index_0]
|
||||
for _index_1 = 1, #_list_2 do
|
||||
local y = _list_2[_index_1]
|
||||
_len_0 = _len_0 + 1
|
||||
_accum_0[_len_0] = x + y
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user