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

ruby-changes:40420

From: shugo <ko1@a...>
Date: Mon, 9 Nov 2015 17:32:56 +0900 (JST)
Subject: [ruby-changes:40420] shugo:r52501 (trunk): * compile.c (iseq_compile_each): Dynamic string literals should be

shugo	2015-11-09 17:32:37 +0900 (Mon, 09 Nov 2015)

  New Revision: 52501

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

  Log:
    * compile.c (iseq_compile_each): Dynamic string literals should be
      frozen.
      [ruby-core:57574] [Feature #8976]

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_iseq.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52500)
+++ ChangeLog	(revision 52501)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov  9 17:29:09 2015  Shugo Maeda  <shugo@r...>
+
+	* compile.c (iseq_compile_each): Dynamic string literals should be
+	  frozen.
+	  [ruby-core:57574] [Feature #8976]
+
 Mon Nov  9 15:56:07 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* common.mk: Use ruby organization url for simplecov repository.
Index: compile.c
===================================================================
--- compile.c	(revision 52500)
+++ compile.c	(revision 52501)
@@ -5130,6 +5130,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5130
 	if (poped) {
 	    ADD_INSN(ret, line, pop);
 	}
+	else {
+	    if (iseq->compile_data->option->frozen_string_literal) {
+		ADD_SEND (ret, line, idFreeze, INT2FIX(0));
+	    }
+	}
 	break;
       }
       case NODE_XSTR:{
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 52500)
+++ test/ruby/test_iseq.rb	(revision 52501)
@@ -175,7 +175,7 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L175
     s1, s2, s3, s4 = compile(code, line, {frozen_string_literal: true}).eval
     assert_predicate(s1, :frozen?)
     assert_predicate(s2, :frozen?)
-    assert_not_predicate(s3, :frozen?)
+    assert_predicate(s3, :frozen?)
     assert_predicate(s4, :frozen?)
     assert_same(s1, s2)
   end

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

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