https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-06-05T02:17:45ZRuby Issue Tracking SystemRuby master - Bug #15830: SortedSet's lazy setup causes unpredictable behaviour in subclass's initializehttps://bugs.ruby-lang.org/issues/15830?journal_id=783462019-06-05T02:17:45Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>File</strong> <a href="/attachments/7817">sorted-set-initialize.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/7817/sorted-set-initialize.patch">sorted-set-initialize.patch</a> added</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>knu (Akinori MUSHA)</i></li></ul><p>I agree this is a bug and the easiest way to fix it is to inline the <code>SortedSet#initialize</code> implementation defined by <code>SortedSet.setup</code> into the default implementation of <code>SortedSet#initialize</code>. Attached is a patch that implements that.</p> Ruby master - Bug #15830: SortedSet's lazy setup causes unpredictable behaviour in subclass's initializehttps://bugs.ruby-lang.org/issues/15830?journal_id=814322019-09-06T21:30:51Zjeremyevans (Jeremy Evans)code@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Fix SortedSet subclasses that override initialize The first time SortedSet#initialize is called,..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/258843106f343d05732499dd1832958eb1bf64f0">git|258843106f343d05732499dd1832958eb1bf64f0</a>.</p>
<hr>
<p>Fix SortedSet subclasses that override initialize</p>
<p>The first time SortedSet#initialize is called, it overwrites<br>
itself, then recalls #initialize, which results in calling the<br>
subclass's initialize, not the current initialize.</p>
<p>Just inline the default initialize behavior to avoid this issue.</p>
<p>No test for this as it can only be triggered the very first time<br>
that SortedSet#initialize is called.</p>
<p>Fixes [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: SortedSet's lazy setup causes unpredictable behaviour in subclass's initialize (Closed)" href="https://bugs.ruby-lang.org/issues/15830">#15830</a>]</p>