Occupy match data

* string.c (rb_str_split_m): occupy match data not to be modified
  during yielding the block.  [Bug #16024]
This commit is contained in:
Nobuyoshi Nakada 2019-07-27 21:54:34 +09:00
parent e3b613a669
commit f1b76ea63c
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 6 additions and 1 deletions

View file

@ -1779,6 +1779,9 @@ CODE
result = []; "".split(//, 1) {|s| result << s}
assert_equal([], result)
result = []; "aaa,bbb,ccc,ddd".split(/,/) {|s| result << s.gsub(/./, "A")}
assert_equal(["AAA"]*4, result)
ensure
EnvUtil.suppress_warning {$; = fs}
end