diff --git a/ChangeLog b/ChangeLog index d83bd5ced3..d0275b7439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 10 11:38:28 2015 Shugo Maeda + + * vm_insnhelper.c (vm_call_method): stop method search when a method + is not found in a refinement, to support undef in refinements. + [ruby-core:66741] [Bug #10578] + Tue Feb 10 11:19:11 2015 Shugo Maeda * lib/net/ftp.rb (chdir, delete, gettextfile, mdtm, mkdir, nlst, diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 3d703e5a3b..d97893cf71 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1387,6 +1387,19 @@ class TestRefinement < Test::Unit::TestCase :foo, bug10826) end + def test_undef_original_method + assert_in_out_err([], <<-INPUT, ["NoMethodError"], []) + module NoPlus + refine String do + undef + + end + end + + using NoPlus + "a" + "b" rescue p($!.class) + INPUT + end + private def eval_using(mod, s) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 02a4503f56..eb3411975e 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1752,6 +1752,10 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) goto start_method_dispatch; } } + else { + ci->me = 0; + goto start_method_dispatch; + } no_refinement_dispatch: if (ci->me->def->body.orig_me) {