diff options
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 7 |
2 files changed, 7 insertions, 2 deletions
@@ -9124,7 +9124,7 @@ rb_str_partition(VALUE str, VALUE sep) pos = rb_reg_search(sep, str, 0, 0); if (pos < 0) { failed: - return rb_ary_new3(3, str, str_new_empty(str), str_new_empty(str)); + return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str)); } sep = rb_str_subpat(str, sep, INT2FIX(0)); if (pos == 0 && RSTRING_LEN(sep) == 0) goto failed; diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index c7f4521e27..b90c620381 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2420,7 +2420,12 @@ CODE end assert_equal(["\u30E6\u30FC\u30B6", "@", "\u30C9\u30E1.\u30A4\u30F3"], - "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/)) + "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/)) + + bug = '[ruby-core:82911]' + hello = "hello" + hello.partition("hi").map(&:upcase!) + assert_equal("hello", hello, bug) end def test_rpartition |