diff --git a/ChangeLog b/ChangeLog index d3132ad619..55b4843d67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 17 01:18:04 2014 Nobuyoshi Nakada + + * eval.c (rb_mod_s_constants): return its own constants for other + than Module itself. [ruby-core:59763] [Bug #9413] + Mon Feb 17 01:16:00 2014 Eric Wong * ext/json/generator/depend: add build dependencies for json extension diff --git a/eval.c b/eval.c index 958daa8752..b5f41e6fcd 100644 --- a/eval.c +++ b/eval.c @@ -377,8 +377,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 91fddabcd0..4bc725d2b5 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -777,6 +777,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 diff --git a/version.h b/version.h index 101ac81d53..ec116411af 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-02-17" -#define RUBY_PATCHLEVEL 428 +#define RUBY_PATCHLEVEL 429 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2