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

ruby-changes:37786

From: nobu <ko1@a...>
Date: Fri, 6 Mar 2015 10:31:26 +0900 (JST)
Subject: [ruby-changes:37786] nobu:r49867 (trunk): vm_eval.c: next super class from the original

nobu	2015-03-06 10:31:03 +0900 (Fri, 06 Mar 2015)

  New Revision: 49867

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

  Log:
    vm_eval.c: next super class from the original
    
    * vm_eval.c (vm_call_super): search next super class from the
      original class, to get rid of infinite recursion with
      prepending.  a patch by Seiei Higa <hanachin AT gmail.com> at
      [ruby-core:68434].  [ruby-core:68093] [Bug #10847]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
    trunk/vm_eval.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49866)
+++ ChangeLog	(revision 49867)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Mar  6 10:31:00 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (vm_call_super): search next super class from the
+	  original class, to get rid of infinite recursion with
+	  prepending.  a patch by Seiei Higa <hanachin AT gmail.com> at
+	  [ruby-core:68434].  [ruby-core:68093] [Bug #10847]
+
 Fri Mar  6 08:45:26 2015  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/matrix.rb: Add Vector#round. Patch by Jordan Stephens.
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 49866)
+++ vm_eval.c	(revision 49867)
@@ -273,7 +273,8 @@ vm_call_super(rb_thread_t *th, int argc, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L273
 	rb_bug("vm_call_super: should not be reached");
     }
 
-    klass = RCLASS_SUPER(cfp->klass);
+    klass = RCLASS_ORIGIN(cfp->klass);
+    klass = RCLASS_SUPER(klass);
     id = cfp->me->def->original_id;
     me = rb_method_entry(klass, id, &klass);
     if (!me) {
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 49866)
+++ test/ruby/test_module.rb	(revision 49867)
@@ -1748,6 +1748,17 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1748
     assert_equal([m, c2, m, c1], c2.ancestors[0, 4], "should accesisble prepended module in superclass")
   end
 
+  def test_prepend_call_super
+    assert_separately([], <<-'end;') #do
+      bug10847 = '[ruby-core:68093] [Bug #10847]'
+      module M; end
+      Float.prepend M
+      assert_nothing_raised(SystemStackError, bug10847) do
+        0.3.numerator
+      end
+    end;
+  end
+
   def test_class_variables
     m = Module.new
     m.class_variable_set(:@@foo, 1)

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

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