summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-01-20 12:24:24 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-01-20 12:24:24 +0900
commit373e62248c9dceb660e95f1cf05fa2a4a469cd64 (patch)
treeaea508abdd61db417f617163763894c990b0a1a2
parent6a8fcb50210f8414d76968298576e39b9fa82562 (diff)
downloadruby-373e62248c9dceb660e95f1cf05fa2a4a469cd64.tar.gz
merge revision(s) f7b72462aa27716370c6bea1f2c240983aca9a55: [Backport #19356]
String#bytesplice should return self In Feature #19314, we concluded that the return value of String#bytesplice should be changed from the source string to the receiver, because the source string is useless and confusing when extra arguments are added. This change should be included in Ruby 3.2.1. --- string.c | 4 ++-- test/ruby/test_string.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
-rw-r--r--string.c4
-rw-r--r--test/ruby/test_string.rb2
-rw-r--r--version.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/string.c b/string.c
index 9fa482dbc7..cae87907c3 100644
--- a/string.c
+++ b/string.c
@@ -6262,7 +6262,7 @@ rb_str_byteslice(int argc, VALUE *argv, VALUE str)
* bytesplice(index, length, str) -> string
* bytesplice(range, str) -> string
*
- * Replaces some or all of the content of +self+ with +str+, and returns +str+.
+ * Replaces some or all of the content of +self+ with +str+, and returns +self+.
* The portion of the string affected is determined using
* the same criteria as String#byteslice, except that +length+ cannot be omitted.
* If the replacement string is not the same length as the text it is replacing,
@@ -6324,7 +6324,7 @@ rb_str_bytesplice(int argc, VALUE *argv, VALUE str)
cr = ENC_CODERANGE_AND(ENC_CODERANGE(str), ENC_CODERANGE(val));
if (cr != ENC_CODERANGE_BROKEN)
ENC_CODERANGE_SET(str, cr);
- return val;
+ return str;
}
/*
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 1ece47b18a..615ede2234 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -3468,7 +3468,7 @@ CODE
private
def assert_bytesplice_result(expected, s, *args)
- assert_equal(args.last, s.send(:bytesplice, *args))
+ assert_equal(expected, s.send(:bytesplice, *args))
assert_equal(expected, s)
end
diff --git a/version.h b/version.h
index 9a73bc2e57..56209ed45e 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 15
+#define RUBY_PATCHLEVEL 16
#include "ruby/version.h"
#include "ruby/internal/abi.h"