mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
fix implicit return with decorated statements
This commit is contained in:
parent
063b50a38f
commit
b404f2d7c8
@ -1228,6 +1228,10 @@ implicitly_return = function(scope)
|
|||||||
local fn
|
local fn
|
||||||
fn = function(stm)
|
fn = function(stm)
|
||||||
local t = ntype(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 types.manual_return[t] or not types.is_value(stm) then
|
||||||
if is_top and t == "return" and stm[2] == "" then
|
if is_top and t == "return" and stm[2] == "" then
|
||||||
return nil
|
return nil
|
||||||
|
@ -627,6 +627,12 @@ implicitly_return = (scope) ->
|
|||||||
is_top = true
|
is_top = true
|
||||||
fn = (stm) ->
|
fn = (stm) ->
|
||||||
t = ntype 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
|
if types.manual_return[t] or not types.is_value stm
|
||||||
-- remove blank return statement
|
-- remove blank return statement
|
||||||
if is_top and t == "return" and stm[2] == ""
|
if is_top and t == "return" and stm[2] == ""
|
||||||
|
@ -57,5 +57,5 @@ y -> return 1
|
|||||||
z -> return 1, "hello", "world"
|
z -> return 1, "hello", "world"
|
||||||
k -> if yes then return else return
|
k -> if yes then return else return
|
||||||
|
|
||||||
|
-> real_name if something
|
||||||
|
|
||||||
|
@ -108,3 +108,8 @@ k(function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
_ = function()
|
||||||
|
if something then
|
||||||
|
return real_name
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user