[Bug #20389] Chilled string cannot be a shared root
This commit is contained in:
parent
95864a6e35
commit
fdd7ffb70c
2
string.c
2
string.c
@ -1340,7 +1340,7 @@ rb_str_new_shared(VALUE str)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_str_new_frozen(VALUE orig)
|
rb_str_new_frozen(VALUE orig)
|
||||||
{
|
{
|
||||||
if (OBJ_FROZEN(orig)) return orig;
|
if (RB_FL_TEST_RAW(orig, FL_FREEZE | STR_CHILLED) == FL_FREEZE) return orig;
|
||||||
return str_new_frozen(rb_obj_class(orig), orig);
|
return str_new_frozen(rb_obj_class(orig), orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3648,6 +3648,18 @@ CODE
|
|||||||
Warning[:deprecated] = deprecated
|
Warning[:deprecated] = deprecated
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_chilled_string_substring
|
||||||
|
deprecated = Warning[:deprecated]
|
||||||
|
Warning[:deprecated] = false
|
||||||
|
chilled_string = eval('"a chilled string."')
|
||||||
|
substring = chilled_string[0..-1]
|
||||||
|
assert_equal("a chilled string.", substring)
|
||||||
|
chilled_string[0..-1] = "This string is defrosted."
|
||||||
|
assert_equal("a chilled string.", substring)
|
||||||
|
ensure
|
||||||
|
Warning[:deprecated] = deprecated
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_bytesplice_result(expected, s, *args)
|
def assert_bytesplice_result(expected, s, *args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user