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

ruby-changes:36030

From: nobu <ko1@a...>
Date: Thu, 23 Oct 2014 19:13:33 +0900 (JST)
Subject: [ruby-changes:36030] nobu:r48111 (trunk): vm_method.c: no redefinition warnings for undefined methods

nobu	2014-10-23 19:13:29 +0900 (Thu, 23 Oct 2014)

  New Revision: 48111

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

  Log:
    vm_method.c: no redefinition warnings for undefined methods
    
    * vm_method.c (rb_method_entry_make): warn redefinition only for
      already defined methods, but not for undefined methods.
      [ruby-dev:48691] [Bug #10421]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_object.rb
    trunk/vm_method.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48110)
+++ ChangeLog	(revision 48111)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Oct 23 19:13:26 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_method.c (rb_method_entry_make): warn redefinition only for
+	  already defined methods, but not for undefined methods.
+	  [ruby-dev:48691] [Bug #10421]
+
 Thu Oct 23 17:19:04 2014  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/source.rb (REXML::IOSource#encoding_updated): Fix a
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 48110)
+++ vm_method.c	(revision 48111)
@@ -379,7 +379,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L379
     }
     /* check mid */
     if (mid == object_id || mid == id__send__) {
-	if (type == VM_METHOD_TYPE_ISEQ) {
+	if (type == VM_METHOD_TYPE_ISEQ && rb_method_boundp(klass, mid, 0)) {
 	    rb_warn("redefining `%s' may cause serious problems", rb_id2name(mid));
 	}
     }
Index: test/ruby/test_object.rb
===================================================================
--- test/ruby/test_object.rb	(revision 48110)
+++ test/ruby/test_object.rb	(revision 48111)
@@ -318,6 +318,12 @@ class TestObject < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_object.rb#L318
       $VERBOSE = false
       def (Object.new).__send__; end
     INPUT
+
+    bug10421 = '[ruby-dev:48691] [Bug #10421]'
+    assert_in_out_err([], <<-INPUT, [], [], bug10421)
+      $VERBOSE = false
+      def (BasicObject.new).object_id; end
+    INPUT
   end
 
   def test_remove_method

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

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