[前][次][番号順一覧][スレッド一覧]

ruby-changes:24612

From: nobu <ko1@a...>
Date: Wed, 8 Aug 2012 22:51:44 +0900 (JST)
Subject: [ruby-changes:24612] nobu:r36663 (trunk): vm_eval.c: cref-scope hack

nobu	2012-08-08 22:51:32 +0900 (Wed, 08 Aug 2012)

  New Revision: 36663

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36663

  Log:
    vm_eval.c: cref-scope hack
    
    * vm_eval.c (eval_under): singletons other than special constants
      don't need cref-scope hack.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_eval.rb
    trunk/vm_eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36662)
+++ ChangeLog	(revision 36663)
@@ -1,3 +1,8 @@
+Wed Aug  8 22:51:30 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* common.mk (.y.h): split from .y.c rule to manage dependency on
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 36662)
+++ vm_eval.c	(revision 36663)
@@ -1320,7 +1320,7 @@
 {
     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) {
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 36662)
+++ test/ruby/test_eval.rb	(revision 36663)
@@ -215,6 +215,18 @@
     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
   #

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]