fix implicit return with decorated statements

This commit is contained in:
leaf corcoran 2012-10-27 12:39:44 -07:00
parent 063b50a38f
commit b404f2d7c8
4 changed files with 17 additions and 2 deletions

View File

@ -1228,6 +1228,10 @@ implicitly_return = function(scope)
local fn
fn = function(stm)
local t = ntype(stm)
if t == "decorated" then
stm = scope.transform.statement(stm)
t = ntype(stm)
end
if types.manual_return[t] or not types.is_value(stm) then
if is_top and t == "return" and stm[2] == "" then
return nil

View File

@ -627,6 +627,12 @@ implicitly_return = (scope) ->
is_top = true
fn = (stm) ->
t = ntype stm
-- expand decorated
if t == "decorated"
stm = scope.transform.statement stm
t = ntype stm
if types.manual_return[t] or not types.is_value stm
-- remove blank return statement
if is_top and t == "return" and stm[2] == ""

View File

@ -57,5 +57,5 @@ y -> return 1
z -> return 1, "hello", "world"
k -> if yes then return else return
-> real_name if something

View File

@ -108,3 +108,8 @@ k(function()
return
end
end)
_ = function()
if something then
return real_name
end
end