Skip to content

Commit 8506fdf

Browse files
committed
merge revision(s) 3b7892b: [Backport #20871]
Fix a bug in rb_include_module that stops nested inclusion into module subclasses This bug was present since the code was originally added by me in 3556a83. Fixes [Bug #20871]
1 parent f19831a commit 8506fdf

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,8 @@ rb_include_module(VALUE klass, VALUE module)
11941194
iclass = iclass->next;
11951195
}
11961196

1197-
int do_include = 1;
11981197
while (iclass) {
1198+
int do_include = 1;
11991199
VALUE check_class = iclass->klass;
12001200
/* During lazy sweeping, iclass->klass could be a dead object that
12011201
* has not yet been swept. */

test/ruby/test_module.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,18 @@ def test_prepend_after_include
784784
assert_equal([:m1, :m0, :m, :sc, :m1, :m0, :c], sc.new.m)
785785
end
786786

787+
def test_include_into_module_after_prepend_bug_20871
788+
bar = Module.new{def bar; 'bar'; end}
789+
foo = Module.new{def foo; 'foo'; end}
790+
m = Module.new
791+
c = Class.new{include m}
792+
m.prepend bar
793+
Class.new{include m}
794+
m.include foo
795+
assert_include c.ancestors, foo
796+
assert_equal "foo", c.new.foo
797+
end
798+
787799
def test_protected_include_into_included_module
788800
m1 = Module.new do
789801
def other_foo(other)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 6
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 112
14+
#define RUBY_PATCHLEVEL 113
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)