aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-27 08:38:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-27 08:38:50 +0000
commit9a1036e4f6473ebda795ee51921920b50a019169 (patch)
tree890d1d82387ccb44bb6ac69411d97ba100590bcd
parent62e161c7ea5752e4a5a7893908262a5b8126b277 (diff)
downloadruby-9a1036e4f6473ebda795ee51921920b50a019169.tar.gz
variable.c: hidden constants
* variable.c (rb_local_constants_i): exclude hidden constants. [ruby-core:75575] [Bug #12389] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_module.rb2
-rw-r--r--variable.c4
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fe7d64c60..c9ddb12f8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri May 27 17:38:49 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * variable.c (rb_local_constants_i): exclude hidden constants.
+ [ruby-core:75575] [Bug #12389]
+
Fri May 27 17:09:44 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* transcode.c (str_transcode0): scrub in the given encoding when
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 65e6a2c4c4..92c3dfd6eb 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -603,6 +603,8 @@ class TestModule < Test::Unit::TestCase
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
diff --git a/variable.c b/variable.c
index db26268cfa..849be3abaa 100644
--- a/variable.c
+++ b/variable.c
@@ -2388,7 +2388,9 @@ 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)
{
- 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;
}