diff --git a/src/JSExpr.jl b/src/JSExpr.jl index a2d5da9..2479a73 100644 --- a/src/JSExpr.jl +++ b/src/JSExpr.jl @@ -91,10 +91,14 @@ function func_expr(args, body) end function insert_return(ex) - isexpr(ex, :block) ? :($(ex.args[1:end-1]...);$(insert_return(ex.args[end]))) : - isexpr(ex, :if) ? Expr(:if, ex.args[1], map(x -> insert_return(x), ex.args[2:end])...) : - isexpr(ex, :return) ? ex : - :(return $ex) + if isa(ex, Symbol) || !isexpr(ex, :block) + Expr(:return, ex) + else + isexpr(ex.args[end], :return) && return ex + ex1 = copy(ex) + ex1.args[end] = insert_return(ex.args[end]) + ex1 + end end