mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
extract declarations doesn't puke on nil statement in body
This commit is contained in:
parent
af2c443807
commit
c9b121c046
@ -99,19 +99,31 @@ extract_declarations = function(self, body, start, out)
|
|||||||
out = { }
|
out = { }
|
||||||
end
|
end
|
||||||
for i = start, #body do
|
for i = start, #body do
|
||||||
local stm = self.transform.statement(body[i])
|
local _continue_0 = false
|
||||||
body[i] = stm
|
repeat
|
||||||
local _exp_0 = stm[1]
|
local stm = body[i]
|
||||||
if "assign" == _exp_0 or "declare" == _exp_0 then
|
if stm == nil then
|
||||||
local _list_0 = stm[2]
|
_continue_0 = true
|
||||||
for _index_0 = 1, #_list_0 do
|
break
|
||||||
local name = _list_0[_index_0]
|
|
||||||
if type(name) == "string" then
|
|
||||||
insert(out, name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif "group" == _exp_0 then
|
stm = self.transform.statement(stm)
|
||||||
extract_declarations(self, stm[2], 1, out)
|
body[i] = stm
|
||||||
|
local _exp_0 = stm[1]
|
||||||
|
if "assign" == _exp_0 or "declare" == _exp_0 then
|
||||||
|
local _list_0 = stm[2]
|
||||||
|
for _index_0 = 1, #_list_0 do
|
||||||
|
local name = _list_0[_index_0]
|
||||||
|
if type(name) == "string" then
|
||||||
|
insert(out, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif "group" == _exp_0 then
|
||||||
|
extract_declarations(self, stm[2], 1, out)
|
||||||
|
end
|
||||||
|
_continue_0 = true
|
||||||
|
until true
|
||||||
|
if not _continue_0 then
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return out
|
return out
|
||||||
|
@ -47,7 +47,9 @@ is_singular = (body) ->
|
|||||||
-- this mutates body searching for assigns
|
-- this mutates body searching for assigns
|
||||||
extract_declarations = (body=@current_stms, start=@current_stm_i + 1, out={}) =>
|
extract_declarations = (body=@current_stms, start=@current_stm_i + 1, out={}) =>
|
||||||
for i=start,#body
|
for i=start,#body
|
||||||
stm = @transform.statement body[i]
|
stm = body[i]
|
||||||
|
continue if stm == nil
|
||||||
|
stm = @transform.statement stm
|
||||||
body[i] = stm
|
body[i] = stm
|
||||||
switch stm[1]
|
switch stm[1]
|
||||||
when "assign", "declare"
|
when "assign", "declare"
|
||||||
|
@ -75,4 +75,9 @@ do
|
|||||||
d = 2323
|
d = 2323
|
||||||
|
|
||||||
|
|
||||||
|
do
|
||||||
|
local *
|
||||||
|
-- this generates a nil value in the body
|
||||||
|
for a in *{} do a
|
||||||
|
|
||||||
g = 2323 -- test if anything leaked
|
g = 2323 -- test if anything leaked
|
||||||
|
@ -70,4 +70,11 @@ do
|
|||||||
d = 200
|
d = 200
|
||||||
d = 2323
|
d = 2323
|
||||||
end
|
end
|
||||||
|
do
|
||||||
|
local _list_0 = { }
|
||||||
|
for _index_0 = 1, #_list_0 do
|
||||||
|
local a = _list_0[_index_0]
|
||||||
|
local _ = a
|
||||||
|
end
|
||||||
|
end
|
||||||
local g = 2323
|
local g = 2323
|
Loading…
Reference in New Issue
Block a user