From e3d7e34e7e34b97ede54b29a4492daaab321de2f Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 31 Mar 2011 05:54:34 +0000 Subject: [PATCH] * eval.c (rb_mod_s_constants): should ignore crefs with the NODE_FL_CREF_PUSHED_BY_EVAL flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 3 ++- test/ruby/test_module.rb | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a493391da7..08dfdb052b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Mar 31 14:50:25 2011 Shugo Maeda + + * eval.c (rb_mod_s_constants): should ignore crefs with + the NODE_FL_CREF_PUSHED_BY_EVAL flag. + Wed Mar 30 22:55:47 2011 Nobuyoshi Nakada * misc/ruby-mode.el (ruby-toggle-block): toggle do/end and {}. diff --git a/eval.c b/eval.c index bbf66b3152..8501f64f5c 100644 --- a/eval.c +++ b/eval.c @@ -322,7 +322,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) while (cref) { klass = cref->nd_clss; - if (!NIL_P(klass)) { + if (!(cref->flags & NODE_FL_CREF_PUSHED_BY_EVAL) && + !NIL_P(klass)) { data = rb_mod_const_at(cref->nd_clss, data); if (!cbase) { cbase = klass; diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 3373594fe3..6a7f566ac7 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -403,6 +403,11 @@ class TestModule < Test::Unit::TestCase p Module.constants - ary, Module.constants(true), Module.constants(false) INPUT assert_in_out_err([], src, %w([:M] [:WALTER] []), []) + + klass = Class.new do + const_set(:X, 123) + end + assert_equal(false, klass.class_eval { Module.constants }.include?(:X)) end module M1