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
|
||||
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
|
||||
|
@ -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] == ""
|
||||
|
@ -57,5 +57,5 @@ y -> return 1
|
||||
z -> return 1, "hello", "world"
|
||||
k -> if yes then return else return
|
||||
|
||||
|
||||
-> real_name if something
|
||||
|
||||
|
@ -107,4 +107,9 @@ k(function()
|
||||
else
|
||||
return
|
||||
end
|
||||
end)
|
||||
end)
|
||||
_ = function()
|
||||
if something then
|
||||
return real_name
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user