You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Insert explicit return expressions in functions/macros/do-blocks
This patch make sure that function and macro definitions, as well as
do-blocks, end with an explicit `return` statement before the last
expression in the body. The following exceptions are made:
- If the last expression is a `for` or `while` loop (which both always
evaluate to `nothing`) `return nothing` is added *after* the loop.
- If the last expression is a `if` or `try` block the `return` is only
added in case there is no `return` inside any of the branches.
- If the last expression is a `let` or `begin` block the `return` is
only added in case there is no `return` inside the block.
- If the last expression is a function call, and the function name is
`throw`, `rethrow`, or `error`, no `return` is added. This is because
it is pretty obvious that these calls terminate the function without
the explicit `return`.
Since adding `return` changes the expression that a macro will see, this
rule is disabled for function definitions inside of macros with the
exception of some known ones from Base (e.g. `@inline`, `@generated`,
...).
Closes#43.
0 commit comments