Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the placeholder subclass entry skipping [Bug #18489] #5455

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,7 @@ rb_include_module(VALUE klass, VALUE module)
if (RB_TYPE_P(klass, T_MODULE)) {
rb_subclass_entry_t *iclass = RCLASS_SUBCLASSES(klass);
// skip the placeholder subclass entry at the head of the list
if (iclass && iclass->next) {
RUBY_ASSERT(!iclass->klass);
if (iclass && !iclass->klass) {
iclass = iclass->next;
}

Expand Down
9 changes: 9 additions & 0 deletions test/ruby/test_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ def test_module_subclass_initialize
assert_not_include(mod.ancestor_list, BasicObject)
end

def test_module_collected_extended_object
m1 = labeled_module("m1")
m2 = labeled_module("m2")
Object.new.extend(m1)
GC.start
m1.include(m2)
assert_equal([m1, m2], m1.ancestors)
end

def test_dup
OtherSetup.call

Expand Down