summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 13:51:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 13:51:32 +0000
commit393ed5c9504e688d3822d79f09d20da7f7195595 (patch)
tree5da20e38eb6f296920e79368418213b187ebd207
parent6b4ecb32fbaf41a97be27bf20781b5fdc38d7485 (diff)
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
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_eval.rb12
-rw-r--r--vm_eval.c2
3 files changed, 18 insertions, 1 deletions
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 <nobu@ruby-lang.org>
+
+ * 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 <nobu@ruby-lang.org>
* 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) {