ruby-changes:43108
From: nobu <ko1@a...>
Date: Fri, 27 May 2016 17:38:58 +0900 (JST)
Subject: [ruby-changes:43108] nobu:r55182 (trunk): variable.c: hidden constants
nobu 2016-05-27 17:38:50 +0900 (Fri, 27 May 2016) New Revision: 55182 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55182 Log: variable.c: hidden constants * variable.c (rb_local_constants_i): exclude hidden constants. [ruby-core:75575] [Bug #12389] Modified files: trunk/ChangeLog trunk/test/ruby/test_module.rb trunk/variable.c Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 55181) +++ test/ruby/test_module.rb (revision 55182) @@ -603,6 +603,8 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L603 const_set(:X, 123) end assert_equal(false, klass.class_eval { Module.constants }.include?(:X)) + + assert_equal(false, Complex.constants(false).include?(:compatible)) end module M1 Index: variable.c =================================================================== --- variable.c (revision 55181) +++ variable.c (revision 55182) @@ -2388,7 +2388,9 @@ sv_i(ID key, VALUE v, void *a) https://github.com/ruby/ruby/blob/trunk/variable.c#L2388 static enum rb_id_table_iterator_result rb_local_constants_i(ID const_name, VALUE const_value, void *ary) { - rb_ary_push((VALUE)ary, ID2SYM(const_name)); + if (rb_is_const_id(const_name)) { + rb_ary_push((VALUE)ary, ID2SYM(const_name)); + } return ID_TABLE_CONTINUE; } Index: ChangeLog =================================================================== --- ChangeLog (revision 55181) +++ ChangeLog (revision 55182) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri May 27 17:38:49 2016 Nobuyoshi Nakada <nobu@r...> + + * variable.c (rb_local_constants_i): exclude hidden constants. + [ruby-core:75575] [Bug #12389] + Fri May 27 17:09:44 2016 Nobuyoshi Nakada <nobu@r...> * transcode.c (str_transcode0): scrub in the given encoding when -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/