From: takashikkbn@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90793] [Ruby trunk Bug#15479][Assigned] Array#reject! modifies literal Array
Date: Sat, 29 Dec 2018 07:28:33 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-75971.20181229072831.39e8be8218258b38@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15479.20181228231833@ruby-lang.org
Issue #15479 has been updated by k0kubun (Takashi Kokubun).
Status changed from Closed to Assigned
oops, closed this ticket by a wrong ticket number in my commit... reopening.
----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-75971
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: tenderlovemaking (Aaron Patterson)
* Target version:
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
* Backport: 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED
----------------------------------------
This was found by running ruby/spec with -R2 (such as mspec -R2 -fs core/array/reject_spec.rb).
TravisCI log on https://travis-ci.org/ruby/spec/jobs/473175799#L539
Here is a simple reproducer.
MRI seems to modify the Array literal permanently:
```ruby
3.times do
a = [1, 2, 3, 4]
puts "initial: #{a}"
begin
a.reject! do |x|
case x
when 2 then true
when 3 then raise StandardError, 'Oops'
else false
end
end
rescue StandardError
end
puts "after: #{a}"
end
```
prints
```
initial: [1, 2, 3, 4]
after: [1, 3, 4]
initial: [1, 3, 4, 4]
after: [1, 3, 4, 4]
initial: [1, 3, 4, 4]
after: [1, 3, 4, 4]
```
2.5.3 behaves fine, but trunk is also affected.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2018-12-29 7:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
2018-12-28 23:18 ` [ruby-core:90781] [Ruby trunk Bug#15479] Array#reject! modifies literal Array eregontp
2018-12-28 23:30 ` [ruby-core:90782] " Greg.mpls
2018-12-29 5:05 ` [ruby-core:90785] " takashikkbn
2018-12-29 5:07 ` [ruby-core:90786] " muraken
2018-12-29 5:07 ` [ruby-core:90787] " takashikkbn
2018-12-29 7:28 ` takashikkbn [this message]
2019-01-08 17:24 ` [ruby-core:90932] " tenderlove
2019-01-08 19:23 ` [ruby-core:90934] " tenderlove
2019-01-10 15:02 ` [ruby-core:91003] " nagachika00
2019-01-17 21:39 ` [ruby-core:91145] " naruse
2019-01-31 10:58 ` [ruby-core:91358] " usa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-75971.20181229072831.39e8be8218258b38@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).