summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 13:47:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 13:47:11 +0000
commit3fd0000c0cf8fedad3b8130b11c2f93a6426d6b0 (patch)
tree81b3b1948e3cc2d48b677f987c855a205613ca75
parent6359460610c0a43d515f3da71b4e8901759d855f (diff)
class.c: exclude original module
* class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--class.c3
-rw-r--r--test/ruby/test_module.rb7
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 824e71e9a1..ab31b7616e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed May 8 22:46:59 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * class.c (rb_mod_included_modules): should not include the original
+ module itself. [ruby-core:53158] [Bug #8025]
+
Wed May 8 17:43:55 2013 NARUSE, Yui <naruse@ruby-lang.org>
* io.c (rb_io_ext_int_to_encs): ignore internal encoding if external
diff --git a/class.c b/class.c
index 9d333fd9b0..29521c44b2 100644
--- a/class.c
+++ b/class.c
@@ -851,9 +851,10 @@ rb_mod_included_modules(VALUE mod)
{
VALUE ary = rb_ary_new();
VALUE p;
+ VALUE origin = RCLASS_ORIGIN(mod);
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
- if (BUILTIN_TYPE(p) == T_ICLASS) {
+ if (p != origin && BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
}
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index f27c11072a..45b5056927 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1548,6 +1548,13 @@ class TestModule < Test::Unit::TestCase
assert_nothing_raised(NoMethodError, bug8005) {a.send :foo}
end
+ def test_prepend_included_modules
+ bug8025 = '[ruby-core:53158] [Bug #8025]'
+ mixin = labeled_module("mixin")
+ c = labeled_module("c") {prepend mixin}
+ assert_not_include(c.included_modules, c, bug8025)
+ end
+
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)