* compile.c (iseq_compile_each): Dynamic string literals (e.g.,
"#{x}") should not be frozen because they don't literally represent strings. https://twitter.com/shugomaeda/status/651937650027401216 https://twitter.com/yukihiro_matz/status/651942882312482817 https://twitter.com/yukihiro_matz/status/651980835181096960 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
68c35d8bb9
commit
b52f1af0d8
@ -1,3 +1,12 @@
|
|||||||
|
Fri Oct 9 12:52:08 2015 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* compile.c (iseq_compile_each): Dynamic string literals (e.g.,
|
||||||
|
"#{x}") should not be frozen because they don't literally
|
||||||
|
represent strings.
|
||||||
|
https://twitter.com/shugomaeda/status/651937650027401216
|
||||||
|
https://twitter.com/yukihiro_matz/status/651942882312482817
|
||||||
|
https://twitter.com/yukihiro_matz/status/651980835181096960
|
||||||
|
|
||||||
Fri Oct 9 06:52:49 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Fri Oct 9 06:52:49 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* benchmark/prepare_require.rb: skip file creation if it already
|
* benchmark/prepare_require.rb: skip file creation if it already
|
||||||
|
@ -5059,11 +5059,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||||||
if (poped) {
|
if (poped) {
|
||||||
ADD_INSN(ret, line, pop);
|
ADD_INSN(ret, line, pop);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (iseq->compile_data->option->frozen_string_literal) {
|
|
||||||
ADD_SEND (ret, line, idFreeze, INT2FIX(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NODE_XSTR:{
|
case NODE_XSTR:{
|
||||||
|
@ -166,12 +166,13 @@ class TestISeq < Test::Unit::TestCase
|
|||||||
$f = 'f'
|
$f = 'f'
|
||||||
line = __LINE__ + 2
|
line = __LINE__ + 2
|
||||||
code = <<-'EOS'
|
code = <<-'EOS'
|
||||||
['foo', 'foo', "#{$f}foo"]
|
['foo', 'foo', "#{$f}foo", "#{'foo'}"]
|
||||||
EOS
|
EOS
|
||||||
s1, s2, s3 = RubyVM::InstructionSequence.compile(code, __FILE__, __FILE__, line, {frozen_string_literal: true}).eval
|
s1, s2, s3, s4 = RubyVM::InstructionSequence.compile(code, __FILE__, __FILE__, line, {frozen_string_literal: true}).eval
|
||||||
assert(s1.frozen?)
|
assert_equal(true, s1.frozen?)
|
||||||
assert(s2.frozen?)
|
assert_equal(true, s2.frozen?)
|
||||||
assert(s3.frozen?)
|
assert_equal(false, s3.frozen?)
|
||||||
assert(s1.object_id == s2.object_id)
|
assert_equal(true, s4.frozen?)
|
||||||
|
assert_equal(s2.object_id, s2.object_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user