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

ruby-changes:33701

From: nobu <ko1@a...>
Date: Fri, 2 May 2014 10:38:04 +0900 (JST)
Subject: [ruby-changes:33701] nobu:r45782 (trunk): parse.y: turn dynamically interned Symbol into an ID

nobu	2014-05-02 10:37:57 +0900 (Fri, 02 May 2014)

  New Revision: 45782

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

  Log:
    parse.y: turn dynamically interned Symbol into an ID
    
    * parse.y (rb_id_attrset): turn dynamically interned Symbol into
      an ID, since rb_str_dynamic_intern returns a Symbol but not an
      ID.  [ruby-core:62226] [Bug #9787]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_symbol.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45781)
+++ ChangeLog	(revision 45782)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May  2 10:37:55 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (rb_id_attrset): turn dynamically interned Symbol into
+	  an ID, since rb_str_dynamic_intern returns a Symbol but not an
+	  ID.  [ruby-core:62226] [Bug #9787]
+
 Thu May  1 22:19:34 2014  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* file.c: Change AND condition to nested condition.
Index: parse.y
===================================================================
--- parse.y	(revision 45781)
+++ parse.y	(revision 45782)
@@ -8862,12 +8862,7 @@ rb_id_attrset(ID id) https://github.com/ruby/ruby/blob/trunk/parse.y#L8862
         /* make new dynamic symbol */
 	str = rb_str_dup(RSYMBOL((VALUE)id)->fstr);
 	rb_str_cat(str, "=", 1);
-	id = (ID)rb_str_dynamic_intern(str);
-	if (ID_DYNAMIC_SYM_P(id)) {
-	    /* attrset ID may have been registered as a static
-	     * symbol */
-	    rb_pin_dynamic_symbol((VALUE)id);
-	}
+	id = SYM2ID(rb_str_dynamic_intern(str));
     }
     return id;
 }
Index: test/ruby/test_symbol.rb
===================================================================
--- test/ruby/test_symbol.rb	(revision 45781)
+++ test/ruby/test_symbol.rb	(revision 45782)
@@ -239,8 +239,8 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L239
   end
 
   def test_gc_attrset
-    bug9787 = '[ruby-core:62226] [Bug #9787]'
-    assert_normal_exit(<<-'end;', '', child_env: '--disable-gems')
+    assert_separately(['-', '[ruby-core:62226] [Bug #9787]'], <<-'end;') #    begin
+      bug = ARGV.shift
       def noninterned_name(prefix = "")
         prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}"
         begin
@@ -248,11 +248,13 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L248
         end while Symbol.find(name) or Symbol.find(name + "=")
         name
       end
-      n = noninterned_name("gc")
-      n.to_sym
+      names = Array.new(1000) {noninterned_name("gc")}
+      names.each {|n| n.to_sym}
       GC.start(immediate_sweep: false)
-      eval(":#{n}=")
-      eval("proc{self.#{n} = nil}")
+      names.each do |n|
+        eval(":#{n}=")
+        assert_nothing_raised(TypeError, bug) {eval("proc{self.#{n} = nil}")}
+      end
     end;
   end
 end

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

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