summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {