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

ruby-changes:34955

From: nobu <ko1@a...>
Date: Sun, 3 Aug 2014 10:43:19 +0900 (JST)
Subject: [ruby-changes:34955] nobu:r47037 (trunk): vm_insnhelper.c: fix unusable super class

nobu	2014-08-03 10:43:10 +0900 (Sun, 03 Aug 2014)

  New Revision: 47037

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

  Log:
    vm_insnhelper.c: fix unusable super class
    
    * vm_insnhelper.c (vm_call_method): unusable super class should cause
      method missing when BasicObject is refined but not been using.
      [ruby-core:64166] [Bug #10106]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_refinement.rb
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47036)
+++ ChangeLog	(revision 47037)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug  3 10:43:08 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_call_method): unusable super class should cause
+	  method missing when BasicObject is refined but not been using.
+	  [ruby-core:64166] [Bug #10106]
+
 Sat Aug  2 23:47:45 2014  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c: separate WIN32OLE::VARIANT src file
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 47036)
+++ vm_insnhelper.c	(revision 47037)
@@ -1823,6 +1823,10 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1823
 		klass = RCLASS_ORIGIN(klass);
 	      zsuper_method_dispatch:
 		klass = RCLASS_SUPER(klass);
+		if (!klass) {
+		    ci->me = 0;
+		    goto start_method_dispatch;
+		}
 		ci_temp = *ci;
 		ci = &ci_temp;
 
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 47036)
+++ test/ruby/test_refinement.rb	(revision 47037)
@@ -1151,6 +1151,21 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1151
     INPUT
   end
 
+  def test_refine_basic_object
+    assert_separately([], <<-"end;")
+    bug10106 = '[ruby-core:64166] [Bug #10106]'
+    module RefinementBug
+      refine BasicObject do
+        def foo
+          1
+        end
+      end
+    end
+
+    assert_raise(NoMethodError, bug10106) {Object.new.foo}
+    end;
+  end
+
   private
 
   def eval_using(mod, s)

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

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