summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-17 08:58:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-17 08:58:05 +0000
commit5c92de87b439d5c5cbe96132b28007bd7326d728 (patch)
treee67e72d57c2605c109d5180d1dec6f0c6e7d62af
parent2c3522c3e403dfdadaaf6095564bde364cc4bddf (diff)
eval.c: singleton class constants
* eval.c (rb_mod_s_constants): return its own constants for other than Module itself. [ruby-core:59763] [Bug #9413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c4
-rw-r--r--test/ruby/test_module.rb13
3 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 754b615cac..27a3c33bdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 17 17:58:04 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_mod_s_constants): return its own constants for other
+ than Module itself. [ruby-core:59763] [Bug #9413]
+
Tue Jan 16 00:17:00 2014 Kenta Murata <mrkn@mrkn.jp>
* ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.5.
diff --git a/eval.c b/eval.c
index 92fbceb1d9..c34dd2cdd9 100644
--- a/eval.c
+++ b/eval.c
@@ -378,8 +378,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
VALUE cbase = 0;
void *data = 0;
- if (argc > 0) {
- return rb_mod_constants(argc, argv, rb_cModule);
+ if (argc > 0 || mod != rb_cModule) {
+ return rb_mod_constants(argc, argv, mod);
}
while (cref) {
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 4f834f0c1e..ba6f273159 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -866,6 +866,19 @@ class TestModule < Test::Unit::TestCase
m.instance_eval { remove_const(:Foo) }
end
+ class Bug9413
+ class << self
+ Foo = :foo
+ end
+ end
+
+ def test_singleton_constants
+ bug9413 = '[ruby-core:59763] [Bug #9413]'
+ c = Bug9413.singleton_class
+ assert_include(c.constants(true), :Foo, bug9413)
+ assert_include(c.constants(false), :Foo, bug9413)
+ end
+
def test_frozen_class
m = Module.new
m.freeze