ruby-changes:19180
From: shugo <ko1@a...>
Date: Thu, 31 Mar 2011 14:54:41 +0900 (JST)
Subject: [ruby-changes:19180] Ruby:r31219 (trunk): * eval.c (rb_mod_s_constants): should ignore crefs with
shugo 2011-03-31 14:54:34 +0900 (Thu, 31 Mar 2011) New Revision: 31219 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31219 Log: * eval.c (rb_mod_s_constants): should ignore crefs with the NODE_FL_CREF_PUSHED_BY_EVAL flag. Modified files: trunk/ChangeLog trunk/eval.c trunk/test/ruby/test_module.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31218) +++ ChangeLog (revision 31219) @@ -1,3 +1,8 @@ +Thu Mar 31 14:50:25 2011 Shugo Maeda <shugo@r...> + + * 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 <nobu@r...> * misc/ruby-mode.el (ruby-toggle-block): toggle do/end and {}. Index: eval.c =================================================================== --- eval.c (revision 31218) +++ eval.c (revision 31219) @@ -322,7 +322,8 @@ 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; Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 31218) +++ test/ruby/test_module.rb (revision 31219) @@ -403,6 +403,11 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/