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,7 +99,14 @@ 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
|
||||||
|
repeat
|
||||||
|
local stm = body[i]
|
||||||
|
if stm == nil then
|
||||||
|
_continue_0 = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
stm = self.transform.statement(stm)
|
||||||
body[i] = stm
|
body[i] = stm
|
||||||
local _exp_0 = stm[1]
|
local _exp_0 = stm[1]
|
||||||
if "assign" == _exp_0 or "declare" == _exp_0 then
|
if "assign" == _exp_0 or "declare" == _exp_0 then
|
||||||
@ -113,6 +120,11 @@ extract_declarations = function(self, body, start, out)
|
|||||||
elseif "group" == _exp_0 then
|
elseif "group" == _exp_0 then
|
||||||
extract_declarations(self, stm[2], 1, out)
|
extract_declarations(self, stm[2], 1, out)
|
||||||
end
|
end
|
||||||
|
_continue_0 = true
|
||||||
|
until true
|
||||||
|
if not _continue_0 then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
@ -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