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

ruby-changes:44704

From: nobu <ko1@a...>
Date: Mon, 14 Nov 2016 14:18:00 +0900 (JST)
Subject: [ruby-changes:44704] nobu:r56777 (trunk): vm_eval.c: fstring instance_eval

nobu	2016-11-14 14:17:55 +0900 (Mon, 14 Nov 2016)

  New Revision: 56777

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56777

  Log:
    vm_eval.c: fstring instance_eval
    
    * vm_eval.c (singleton_class_for_eval): enable fstring singleton
      class for instance_eval.  [ruby-core:78116] [Bug #12930]

  Modified files:
    trunk/test/ruby/test_eval.rb
    trunk/vm_eval.c
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 56776)
+++ vm_eval.c	(revision 56777)
@@ -1669,6 +1669,8 @@ singleton_class_for_eval(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1669
     switch (BUILTIN_TYPE(self)) {
       case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
 	return Qnil;
+      case T_STRING:
+	if (FL_TEST_RAW(self, RSTRING_FSTR)) return Qnil;
       default:
 	return rb_singleton_class(self);
     }
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 56776)
+++ test/ruby/test_eval.rb	(revision 56777)
@@ -503,6 +503,14 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L503
     assert_same a, b
   end
 
+  def test_fstring_instance_eval
+    bug = "[ruby-core:78116] [Bug #12930]".freeze
+    assert_same bug, (bug.instance_eval {self})
+    assert_raise(RuntimeError) {
+      bug.instance_eval {@ivar = true}
+    }
+  end
+
   def test_gced_binding_block
     assert_normal_exit %q{
       def m

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

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