Skip to content

Commit

Permalink
fix JuliaLang#14323, error check for un-terminated body Exprs
Browse files Browse the repository at this point in the history
`body` is part of the low-level IR and shouldn't be generated by macros.
  • Loading branch information
JeffBezanson committed Dec 8, 2015
1 parent 55fd7b1 commit 45a6383
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,11 @@ static jl_value_t *eval_body(jl_array_t *stmts, jl_value_t **locals, size_t nl,
int start, int toplevel)
{
jl_handler_t __eh;
size_t i=start;
size_t i=start, ns = jl_array_len(stmts);

while (1) {
if (i >= ns)
jl_error("`body` expression must terminate in `return`. Use `block` instead.");
jl_value_t *stmt = jl_cellref(stmts,i);
if (jl_is_gotonode(stmt)) {
i = label_idx(jl_gotonode_label(stmt), stmts);
Expand Down
3 changes: 3 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3536,3 +3536,6 @@ let
finalize(obj2)
@test finalized == 4
end

# issue #14323
@test_throws ErrorException eval(Expr(:body, :(1)))

0 comments on commit 45a6383

Please sign in to comment.