[Bug #19833] Fix index underflow at superclasses of BasicObject
This commit is contained in:
parent
69292676a2
commit
72d1a790cf
Notes:
git
2023-08-08 10:55:38 +00:00
4
object.c
4
object.c
@ -2165,6 +2165,10 @@ rb_class_superclass(VALUE klass)
|
||||
if (klass == rb_cBasicObject) return Qnil;
|
||||
rb_raise(rb_eTypeError, "uninitialized class");
|
||||
}
|
||||
|
||||
if (!RCLASS_SUPERCLASS_DEPTH(klass)) {
|
||||
return Qnil;
|
||||
}
|
||||
else {
|
||||
super = RCLASS_SUPERCLASSES(klass)[RCLASS_SUPERCLASS_DEPTH(klass) - 1];
|
||||
RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
|
||||
|
@ -96,6 +96,13 @@ class TestClass < Test::Unit::TestCase
|
||||
|
||||
def test_superclass_of_basicobject
|
||||
assert_equal(nil, BasicObject.superclass)
|
||||
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
module Mod end
|
||||
BasicObject.include(Mod)
|
||||
assert_equal(nil, BasicObject.superclass)
|
||||
end;
|
||||
end
|
||||
|
||||
def test_module_function
|
||||
|
Loading…
x
Reference in New Issue
Block a user