declare the variables introduced by for loop into scope #44

This commit is contained in:
leaf corcoran 2012-09-18 16:04:22 -07:00
parent 43c1e0a4fb
commit 98ebb97b16
3 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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) =>

View File

@ -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