https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2018-12-28T23:30:27Z
Ruby Issue Tracking System
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75955
2018-12-28T23:30:27Z
MSP-Greg (Greg L)
<ul></ul><p>Is the distinction really whether 2.6.0 & trunk only modify the array if <code>reject!</code> successfully enumerates all array members?</p>
<p>But if so, why does it modify the first loop? Strange behavior...</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75958
2018-12-29T05:05:30Z
k0kubun (Takashi Kokubun)
takashikkbn@gmail.com
<ul><li><strong>Assignee</strong> set to <i>tenderlovemaking (Aaron Patterson)</i></li></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/73">@tenderlovemaking (Aaron Patterson)</a> According to git bisect, <a href="https://github.com/ruby/ruby/commit/d46cd60f3cfb88f1591d6ce0f23e750d3833434f" class="external">https://github.com/ruby/ruby/commit/d46cd60f3cfb88f1591d6ce0f23e750d3833434f</a> (Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Accept "target" keyword on `TracePoint#enable` (Closed)" href="https://bugs.ruby-lang.org/issues/15289">#15289</a>) seems to have triggered this. Could you check it?</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75959
2018-12-29T05:07:02Z
mrkn (Kenta Murata)
muraken@gmail.com
<ul></ul><p>This is a smaller reproducible code.</p>
<pre><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]
</code></pre>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75960
2018-12-29T05:07:19Z
k0kubun (Takashi Kokubun)
takashikkbn@gmail.com
<ul></ul><p>Oops, I copy-pasted the ticket number in the commit message, but actually it should have been Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Use a shared array for the `duparray` instruction (Closed)" href="https://bugs.ruby-lang.org/issues/15349">#15349</a>.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75962
2018-12-29T05:07:32Z
k0kubun (Takashi Kokubun)
takashikkbn@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/15349">Feature #15349</a>: Use a shared array for the `duparray` instruction</i> added</li></ul>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75963
2018-12-29T05:08:20Z
mrkn (Kenta Murata)
muraken@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li></ul>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75970
2018-12-29T07:26:26Z
k0kubun (Takashi Kokubun)
takashikkbn@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r66632.</p>
<hr>
<p>erb.rb: increase warn level only when non-zero safe_level</p>
<p>is given.</p>
<p>This is merging Eric's patch in [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Array#reject! modifies literal Array (Closed)" href="https://bugs.ruby-lang.org/issues/15479">#15479</a>] to Ruby 2.6's behavior in r66631.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=75971
2018-12-29T07:28:31Z
k0kubun (Takashi Kokubun)
takashikkbn@gmail.com
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul><p>oops, closed this ticket by a wrong ticket number in my commit... reopening.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76129
2019-01-08T17:24:21Z
tenderlovemaking (Aaron Patterson)
tenderlove@ruby-lang.org
<ul></ul><p>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:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">foo</span>
<span class="n">b</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
<span class="mi">3</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">b</span><span class="p">.</span><span class="nf">dup</span>
<span class="nb">puts</span> <span class="s2">"initial: </span><span class="si">#{</span><span class="n">a</span><span class="si">}</span><span class="s2">"</span>
<span class="k">begin</span>
<span class="n">a</span><span class="p">.</span><span class="nf">reject!</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
<span class="k">case</span> <span class="n">x</span>
<span class="k">when</span> <span class="mi">2</span> <span class="k">then</span> <span class="kp">true</span>
<span class="k">when</span> <span class="mi">3</span> <span class="k">then</span> <span class="k">raise</span> <span class="no">StandardError</span><span class="p">,</span> <span class="s1">'Oops'</span>
<span class="k">else</span> <span class="kp">false</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">rescue</span> <span class="no">StandardError</span>
<span class="k">end</span>
<span class="nb">puts</span> <span class="s2">"after: </span><span class="si">#{</span><span class="n">a</span><span class="si">}</span><span class="s2">"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">foo</span>
</code></pre>
<p>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.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76131
2019-01-08T19:22:14Z
tenderlovemaking (Aaron Patterson)
tenderlove@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r66756.</p>
<hr>
<p>Mark array as "going to be modified" in <code>Array#reject!</code></p>
<p>Before this patch, if <code>reject!</code> is called on a shared array it can<br>
mutate the shared array rather than a copy. This patch marks the array<br>
as "going to be modified" so that the shared source array isn't<br>
mutated.</p>
<p>[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Array#reject! modifies literal Array (Closed)" href="https://bugs.ruby-lang.org/issues/15479">#15479</a>] <a href="/issues/15479">[ruby-core:90781]</a></p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76132
2019-01-08T19:23:40Z
tenderlovemaking (Aaron Patterson)
tenderlove@ruby-lang.org
<ul><li><strong>Backport</strong> changed from <i>2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED</i> to <i>2.4: REQUIRED, 2.5: REQUIRED, 2.6: REQUIRED</i></li></ul><p>r66756 should be backported, so I updated the backport field.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76224
2019-01-10T15:02:25Z
nagachika (Tomoyuki Chikanaga)
nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.4: REQUIRED, 2.5: REQUIRED, 2.6: REQUIRED</i> to <i>2.4: REQUIRED, 2.5: DONE, 2.6: REQUIRED</i></li></ul><p>ruby_2_5 r66784 merged revision(s) 66756.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76375
2019-01-17T21:39:22Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul><li><strong>Backport</strong> changed from <i>2.4: REQUIRED, 2.5: DONE, 2.6: REQUIRED</i> to <i>2.4: REQUIRED, 2.5: DONE, 2.6: DONE</i></li></ul><p>ruby_2_6 r66847 merged revision(s) 66756.</p>
Ruby master - Bug #15479: Array#reject! modifies literal Array
https://bugs.ruby-lang.org/issues/15479?journal_id=76611
2019-01-31T10:58:52Z
usa (Usaku NAKAMURA)
usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.4: REQUIRED, 2.5: DONE, 2.6: DONE</i> to <i>2.4: DONE, 2.5: DONE, 2.6: DONE</i></li></ul><p>ruby_2_4 r66966 merged revision(s) 66756.</p>