diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 2ef5b5e080..38da8b6c45 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -741,4 +741,16 @@ class TestRubyOptimization < Test::Unit::TestCase end assert_equal(:ok, obj.a()) end + + def test_blockparam_in_rescue + obj = Object.new + def obj.foo(&b) + raise + rescue + b.call + end + result = nil + assert_equal(42, obj.foo {result = 42}) + assert_equal(42, result) + end end diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 71e579aed4..0bab81e906 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2083,7 +2083,7 @@ vm_call_opt_call(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct static VALUE vm_call_opt_block_call(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc) { - VALUE block_handler = VM_ENV_BLOCK_HANDLER(reg_cfp->ep); + VALUE block_handler = VM_ENV_BLOCK_HANDLER(VM_CF_LEP(reg_cfp)); if (BASIC_OP_UNREDEFINED_P(BOP_CALL, PROC_REDEFINED_OP_FLAG)) { return vm_invoke_block_opt_call(ec, reg_cfp, calling, ci, block_handler);