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

ruby-changes:9493

From: yugui <ko1@a...>
Date: Thu, 25 Dec 2008 18:58:34 +0900 (JST)
Subject: [ruby-changes:9493] Ruby:r21034 (ruby_1_9_1): merges r20981 and r20985 from trunk into ruby_1_9_1.

yugui	2008-12-25 18:57:05 +0900 (Thu, 25 Dec 2008)

  New Revision: 21034

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

  Log:
    merges r20981 and r20985 from trunk into ruby_1_9_1.
    * vm_insnhelper.c (vm_method_search): return rb_cObject if there is no
      super class.  [ruby-dev:37587]
    * bootstraptest/test_method.rb: add tests for above.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/bootstraptest/test_method.rb
    branches/ruby_1_9_1/vm_insnhelper.c

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 21033)
+++ ruby_1_9_1/ChangeLog	(revision 21034)
@@ -1,3 +1,15 @@
+Thu Dec 25 14:32:23 2008  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (vm_method_search): fix control flow bug.
+	  (commited at r20981)
+
+Thu Dec 25 13:13:00 2008  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (vm_method_search): return rb_cObject if there is no
+	  super class.  [ruby-dev:37587]
+
+	* bootstraptest/test_method.rb: add tests for above.
+
 Thu Dec 25 12:49:12 2008  Koichi Sasada  <ko1@a...>
 
 	* proc.c (proc_new): should use proc_dup() if block has Proc.
Index: ruby_1_9_1/bootstraptest/test_method.rb
===================================================================
--- ruby_1_9_1/bootstraptest/test_method.rb	(revision 21033)
+++ ruby_1_9_1/bootstraptest/test_method.rb	(revision 21034)
@@ -1103,3 +1103,40 @@
 
   C.new.m
 }
+
+assert_equal 'ok', %q{
+  module Foo
+    def foo
+      begin
+        super
+      rescue NoMethodError
+        :ok
+      end
+    end
+    module_function :foo
+  end
+  Foo.foo
+}, '[ruby-dev:37587]'
+
+assert_equal 'Object#foo', %q{
+  class Object
+    def self.foo
+      "Object.foo"
+    end
+    def foo
+      "Object#foo"
+    end
+  end
+
+  module Foo
+    def foo
+      begin
+        super
+      rescue NoMethodError
+        :ok
+      end
+    end
+    module_function :foo
+  end
+  Foo.foo
+}, '[ruby-dev:37587]'
Index: ruby_1_9_1/vm_insnhelper.c
===================================================================
--- ruby_1_9_1/vm_insnhelper.c	(revision 21033)
+++ ruby_1_9_1/vm_insnhelper.c	(revision 21034)
@@ -1173,19 +1173,21 @@
 vm_search_normal_superclass(VALUE klass, VALUE recv)
 {
     if (BUILTIN_TYPE(klass) == T_CLASS) {
-	klass = RCLASS_SUPER(klass);
+	return RCLASS_SUPER(klass);
     }
     else if (BUILTIN_TYPE(klass) == T_MODULE) {
 	VALUE k = CLASS_OF(recv);
 	while (k) {
 	    if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) {
-		klass = RCLASS_SUPER(k);
-		break;
+		return RCLASS_SUPER(k);
 	    }
 	    k = RCLASS_SUPER(k);
 	}
+	return rb_cObject;
     }
-    return klass;
+    else {
+	rb_bug("vm_search_normal_superclass: should not be reach here");
+    }
 }
 
 static void

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

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