summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:57:05 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:57:05 +0000
commit78e7472cad31f597134d9fa28c8992d450b47f43 (patch)
tree29f363ceb87c33057062ac3064457d3bb2ab31a0
parentdcc293e053ee845446396b85950fd95cf62bbcb3 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--bootstraptest/test_method.rb37
-rw-r--r--vm_insnhelper.c10
3 files changed, 55 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 74a7023acd..a678de8b2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Dec 25 14:32:23 2008 Koichi Sasada <ko1@atdot.net>
+
+ * vm_insnhelper.c (vm_method_search): fix control flow bug.
+ (commited at r20981)
+
+Thu Dec 25 13:13:00 2008 Koichi Sasada <ko1@atdot.net>
+
+ * 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@atdot.net>
* proc.c (proc_new): should use proc_dup() if block has Proc.
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
index fff484db73..136fce4970 100644
--- a/bootstraptest/test_method.rb
+++ b/bootstraptest/test_method.rb
@@ -1103,3 +1103,40 @@ assert_equal '["B", "A"]', %q{
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]'
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 1a8d3df6ec..71a673e37e 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1173,19 +1173,21 @@ static inline VALUE
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;
+ }
+ else {
+ rb_bug("vm_search_normal_superclass: should not be reach here");
}
- return klass;
}
static void