ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:90781] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
@ 2018-12-28 23:18 ` eregontp
  2018-12-28 23:30 ` [ruby-core:90782] " Greg.mpls
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: eregontp @ 2018-12-28 23:18 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been reported by Eregon (Benoit Daloze).

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90782] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [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 ` Greg.mpls
  2018-12-29  5:05 ` [ruby-core:90785] " takashikkbn
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: Greg.mpls @ 2018-12-28 23:30 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by MSP-Greg (Greg L).


Is the distinction really whether 2.6.0 & trunk only modify the array if `reject!` successfully enumerates all array members?

Commenting out `when 3 then raise StandardError, 'Oops'`, all versions act the same...

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-75955

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90785] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [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 ` takashikkbn
  2018-12-29  5:07 ` [ruby-core:90786] " muraken
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: takashikkbn @ 2018-12-29  5:05 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by k0kubun (Takashi Kokubun).

Assignee set to tenderlovemaking (Aaron Patterson)

@tenderlovemaking According to git bisect, https://github.com/ruby/ruby/commit/d46cd60f3cfb88f1591d6ce0f23e750d3833434f (Feature #15289) seems to have triggered this. Could you check it?

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-75958

* Author: Eregon (Benoit Daloze)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90786] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-12-29  5:05 ` [ruby-core:90785] " takashikkbn
@ 2018-12-29  5:07 ` muraken
  2018-12-29  5:07 ` [ruby-core:90787] " takashikkbn
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: muraken @ 2018-12-29  5:07 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by mrkn (Kenta Murata).


This is a smaller reproducible code.

```
mrkn-mbp15-late2016:bigdecimal mrkn$ cat t.rb
def foo
  a = [1, 2, 3, 4]
  a.reject! {|x|
    next true if x == 2
    return a if x == 3
    false
  }
end

p foo
p foo
mrkn-mbp15-late2016:bigdecimal mrkn$ ruby -v t.rb
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
[1, 3, 4]
[1, 3, 4, 4]
```

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-75959

* Author: Eregon (Benoit Daloze)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90787] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2018-12-29  5:07 ` [ruby-core:90786] " muraken
@ 2018-12-29  5:07 ` takashikkbn
  2018-12-29  7:28 ` [ruby-core:90793] [Ruby trunk Bug#15479][Assigned] " takashikkbn
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: takashikkbn @ 2018-12-29  5:07 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by k0kubun (Takashi Kokubun).


Oops, I copy-pasted the ticket number in the commit message, but actually it should have been Feature #15349.

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-75960

* Author: Eregon (Benoit Daloze)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90793] [Ruby trunk Bug#15479][Assigned] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2018-12-29  5:07 ` [ruby-core:90787] " takashikkbn
@ 2018-12-29  7:28 ` takashikkbn
  2019-01-08 17:24 ` [ruby-core:90932] [Ruby trunk Bug#15479] " tenderlove
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: takashikkbn @ 2018-12-29  7:28 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90932] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2018-12-29  7:28 ` [ruby-core:90793] [Ruby trunk Bug#15479][Assigned] " takashikkbn
@ 2019-01-08 17:24 ` tenderlove
  2019-01-08 19:23 ` [ruby-core:90934] " tenderlove
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: tenderlove @ 2019-01-08 17:24 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by tenderlovemaking (Aaron Patterson).


It seems like this is also a bug in Ruby 2.5 and Ruby 2.4.  If you modify the test program a little bit like this:

~~~ ruby
def foo
  b = [1, 2, 3, 4]
  3.times do
    a = b.dup
    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
end

foo
~~~

It will fail on 2.4.X, 2.5.X, and 2.6.  It seems like "reject!" isn't unsharing the array.  I will make a patch to fix this.


----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-76129

* 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:90934] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-01-08 17:24 ` [ruby-core:90932] [Ruby trunk Bug#15479] " tenderlove
@ 2019-01-08 19:23 ` tenderlove
  2019-01-10 15:02 ` [ruby-core:91003] " nagachika00
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: tenderlove @ 2019-01-08 19:23 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by tenderlovemaking (Aaron Patterson).

Backport changed from 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED to 2.4: REQUIRED, 2.5: REQUIRED, 2.6: REQUIRED

r66756 should be backported, so I updated the backport field.

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-76132

* Author: Eregon (Benoit Daloze)
* Status: Closed
* 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: REQUIRED, 2.5: REQUIRED, 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:91003] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-01-08 19:23 ` [ruby-core:90934] " tenderlove
@ 2019-01-10 15:02 ` nagachika00
  2019-01-17 21:39 ` [ruby-core:91145] " naruse
  2019-01-31 10:58 ` [ruby-core:91358] " usa
  10 siblings, 0 replies; 11+ messages in thread
From: nagachika00 @ 2019-01-10 15:02 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.4: REQUIRED, 2.5: REQUIRED, 2.6: REQUIRED to 2.4: REQUIRED, 2.5: DONE, 2.6: REQUIRED

ruby_2_5 r66784 merged revision(s) 66756.

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-76224

* Author: Eregon (Benoit Daloze)
* Status: Closed
* 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: REQUIRED, 2.5: DONE, 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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:91145] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2019-01-10 15:02 ` [ruby-core:91003] " nagachika00
@ 2019-01-17 21:39 ` naruse
  2019-01-31 10:58 ` [ruby-core:91358] " usa
  10 siblings, 0 replies; 11+ messages in thread
From: naruse @ 2019-01-17 21:39 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by naruse (Yui NARUSE).

Backport changed from 2.4: REQUIRED, 2.5: DONE, 2.6: REQUIRED to 2.4: REQUIRED, 2.5: DONE, 2.6: DONE

ruby_2_6 r66847 merged revision(s) 66756.

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-76375

* Author: Eregon (Benoit Daloze)
* Status: Closed
* 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: REQUIRED, 2.5: DONE, 2.6: DONE
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:91358] [Ruby trunk Bug#15479] Array#reject! modifies literal Array
       [not found] <redmine.issue-15479.20181228231833@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2019-01-17 21:39 ` [ruby-core:91145] " naruse
@ 2019-01-31 10:58 ` usa
  10 siblings, 0 replies; 11+ messages in thread
From: usa @ 2019-01-31 10:58 UTC (permalink / raw
  To: ruby-core

Issue #15479 has been updated by usa (Usaku NAKAMURA).

Backport changed from 2.4: REQUIRED, 2.5: DONE, 2.6: DONE to 2.4: DONE, 2.5: DONE, 2.6: DONE

ruby_2_4 r66966 merged revision(s) 66756.

----------------------------------------
Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479#change-76611

* Author: Eregon (Benoit Daloze)
* Status: Closed
* 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: DONE, 2.5: DONE, 2.6: DONE
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-01-31 10:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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 ` [ruby-core:90793] [Ruby trunk Bug#15479][Assigned] " takashikkbn
2019-01-08 17:24 ` [ruby-core:90932] [Ruby trunk Bug#15479] " 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

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).