From 393ed5c9504e688d3822d79f09d20da7f7195595 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 8 Aug 2012 13:51:32 +0000 Subject: vm_eval.c: cref-scope hack * vm_eval.c (eval_under): singletons other than special constants don't need cref-scope hack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_eval.rb | 12 ++++++++++++ vm_eval.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 15174d0dbb..cfc3c30378 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Aug 8 22:51:30 2012 Nobuyoshi Nakada + + * vm_eval.c (eval_under): singletons other than special constants + don't need cref-scope hack. + Wed Aug 8 22:45:38 2012 Nobuyoshi Nakada * common.mk (.y.h): split from .y.c rule to manage dependency on diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 1d976b3052..e1de99c847 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -215,6 +215,18 @@ class TestEval < Test::Unit::TestCase end end + class Foo + Bar = 2 + end + + def test_instance_eval_const + bar = nil + assert_nothing_raised(NameError) do + bar = Foo.new.instance_eval("Bar") + end + assert_equal(2, bar) + end + # # From ruby/test/ruby/test_eval.rb # diff --git a/vm_eval.c b/vm_eval.c index 216607e439..04ae8fa422 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1320,7 +1320,7 @@ eval_under(VALUE under, VALUE self, VALUE src, const char *file, int line) { NODE *cref = vm_cref_push(GET_THREAD(), under, NOEX_PUBLIC, NULL); - if (FL_TEST(under, FL_SINGLETON) || (SPECIAL_CONST_P(self) && !NIL_P(under))) { + if (SPECIAL_CONST_P(self) && !NIL_P(under)) { cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL; } if (rb_safe_level() >= 4) { -- cgit v1.2.3