Skip to content

Commit

Permalink
Should raise LocalJumpError when no block given
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Jul 14, 2016
1 parent d4d807b commit 9dc8205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,10 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
}
stack = e->stack + 1;
}
if (mrb_nil_p(stack[m1+r+m2])) {
localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
goto L_RAISE;
}
regs[a] = stack[m1+r+m2];
NEXT;
}
Expand Down
7 changes: 7 additions & 0 deletions test/t/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def bar(*a)
assert_raise LocalJumpError do
yield
end
assert_raise LocalJumpError do
o = Object.new
def o.foo
yield
end
o.foo
end
end

assert('Abbreviated variable assignment', '11.4.2.3.2') do
Expand Down

0 comments on commit 9dc8205

Please sign in to comment.