[前][次][番号順一覧][スレッド一覧]

ruby-changes:37473

From: shugo <ko1@a...>
Date: Tue, 10 Feb 2015 11:40:28 +0900 (JST)
Subject: [ruby-changes:37473] shugo:r49554 (trunk): * vm_insnhelper.c (vm_call_method): stop method search when a method

shugo	2015-02-10 11:40:21 +0900 (Tue, 10 Feb 2015)

  New Revision: 49554

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49554

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_refinement.rb
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49553)
+++ ChangeLog	(revision 49554)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Feb 10 11:38:28 2015  Shugo Maeda  <shugo@r...>
+
+	* 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  <shugo@r...>
 
 	* lib/net/ftp.rb (chdir, delete, gettextfile, mdtm, mkdir, nlst,
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 49553)
+++ vm_insnhelper.c	(revision 49554)
@@ -1752,6 +1752,10 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1752
 			goto start_method_dispatch;
 		    }
 		}
+		else {
+		    ci->me = 0;
+		    goto start_method_dispatch;
+		}
 
 	      no_refinement_dispatch:
 		if (ci->me->def->body.orig_me) {
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 49553)
+++ test/ruby/test_refinement.rb	(revision 49554)
@@ -1387,6 +1387,19 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1387
                    :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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]