diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 2 | ||||
-rw-r--r-- | variable.c | 2 |
3 files changed, 8 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Tue Jul 19 15:38:59 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * variable.c (rb_local_constants_i): exclude private constants + when excluding inherited constants too. [Bug #12345] + Sun Jul 17 23:42:00 2016 Kenta Murata <mrkn@mrkn.jp> * numeric.c (num_finite_p, num_infinite_p): Add Numeric#finite? and diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 92c3dfd6eb..0f9351c57d 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1423,6 +1423,8 @@ class TestModule < Test::Unit::TestCase def test_constants_with_private_constant assert_not_include(::TestModule.constants, :PrivateClass) + assert_not_include(::TestModule.constants(true), :PrivateClass) + assert_not_include(::TestModule.constants(false), :PrivateClass) end def test_toplevel_private_constant diff --git a/variable.c b/variable.c index 4d3222b5db..0966685690 100644 --- a/variable.c +++ b/variable.c @@ -2399,7 +2399,7 @@ sv_i(ID key, VALUE v, void *a) static enum rb_id_table_iterator_result rb_local_constants_i(ID const_name, VALUE const_value, void *ary) { - if (rb_is_const_id(const_name)) { + if (rb_is_const_id(const_name) && !RB_CONST_PRIVATE_P((rb_const_entry_t *)const_value)) { rb_ary_push((VALUE)ary, ID2SYM(const_name)); } return ID_TABLE_CONTINUE; |