https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-02-01T21:56:07ZRuby Issue Tracking SystemRuby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=357592013-02-01T21:56:07ZAnonymous
<ul><li><strong>Target version</strong> set to <i>2.0.0</i></li><li><strong>Assignee</strong> set to <i>Anonymous</i></li></ul><p>=begin<br>
Looks like a regression introduced in r26987<br>
=end</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=357612013-02-01T23:05:55ZAnonymous
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r39004.<br>
Roman, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>array.c (rb_ary_dup): make returned array the same class as the original<br>
array [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Inherited Array class missing (Closed)" href="https://redmine.ruby-lang.org/issues/7768">#7768</a>] <a href="/issues/7768">[ruby-core:51792]</a></li>
<li>test/ruby/test_array.rb (class TestArray): add test</li>
</ul> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=357642013-02-02T01:35:57Zmrkn (Kenta Murata)muraken@gmail.com
<ul></ul><p><a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Arrayを継承したオブジェクトのcompactがArrayを返す (Closed)" href="https://redmine.ruby-lang.org/issues/7625">#7625</a> is related to this issue.</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=359872013-02-07T23:22:18ZAnonymous
<ul></ul><p>=begin<br>
Summary of my discussion with mame in #ruby-core:</p>
<p>[00:33:08] r30148<br>
[00:34:16] some people complains to your r39004<br>
[00:34:43] because it might be an intentional change by matz at r30148<br>
[00:34:53] <a href="http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=30148&view=revision" class="external">http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=30148&view=revision</a><br>
[00:35:09] * array.c (rb_ary_dup): should copy contents only. no instance<br>
[00:35:09] variable, no class would be copied.<br>
[00:36:04] The point is that don't change behavior without matz's accept<br>
[00:36:09] however, matz is now saying the opposite opinion against himself<br>
[00:36:38] sorry for changing behaviour<br>
[00:36:44] he now prefers the old 1.9.3 behavior<br>
[00:36:59] the bug looked like a regression, but i fixed the wrong place<br>
[00:37:25] oops, 1.9.3 behavior -> 1.9.2 behavior<br>
[00:38:53] indeed rb_ary_dup impacts too extensively a little<br>
[00:39:10] then how do you fix?<br>
[00:39:36] so this was the bug <a href="http://bugs.ruby-lang.org/issues/7768" class="external">http://bugs.ruby-lang.org/issues/7768</a><br>
[00:40:25] fix only Array#uniq ?<br>
[00:40:35] mame1: that would be the least intrusive way<br>
[00:41:16] mame1: do you want me to do it?<br>
[00:42:22] could you create a patch for the way?<br>
[00:42:36] sure, one moment<br>
[00:43:25] just confirm: you didn't intend to change the behavior of other methods than Array#uniq, right?<br>
[00:43:53] then, it looks good to me to choose "the least intrusive way"<br>
[00:44:26] mame1: i thought that perhaps there were other methods that would behave inconsistently in some cases like #uniq<br>
[00:44:47] but i will give you a patch that undoes it<br>
[00:45:19] honestly i agree with you to some extent<br>
[00:45:33] but the timing is bad a little<br>
[00:45:39] yes, i agree<br>
[00:45:41] sorry once again<br>
[00:46:07] something to discuss after 2.0 is released maybe?<br>
[00:46:18] no prob, thank you for your cooperation<br>
[00:46:35] no plan :-)<br>
[00:47:12] ah, it may be difficult to change 2.0.0 after 2.0.0-p0 is released<br>
[00:47:38] for next minor, i mean<br>
[00:47:41] 2.0.1 or 2.1.0 will include the change, which matz will decide<br>
[00:47:49] yes<br>
[00:48:29] mame1: <a href="https://gist.github.com/charliesome/adeff49e900f6b8a75fc" class="external">https://gist.github.com/charliesome/adeff49e900f6b8a75fc</a><br>
[00:48:55] the test i added in r39004 still passes<br>
[00:49:11] so i think this is ok if you're happy to change Array#uniq's behaviour<br>
[00:51:31] charliesome: it is really a regression, isn't it?<br>
[00:52:04] mame1: i think so - see <a href="http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/26987/diff/array.c" class="external">http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/26987/diff/array.c</a><br>
[00:52:19] it looks like an attempt at an optimization<br>
[00:52:51] yeah, i've seen the diff, but i've not checked the other region of code<br>
[00:53:15] mame1: maybe the safest option is to revert r39004 completely?<br>
[00:53:38] it returns a new object whose class is the same of the argument, say, when its length is >= 2?<br>
[00:53:45] mame1: yes<br>
[00:54:22] hmm, thanks. let me consider for a minute :-)<br>
[00:54:28] no problem<br>
[01:15:14] charliesome: sorry for let you wait<br>
[01:15:25] i decided that i'll release rc2 with the <em>current</em> behavior<br>
[01:15:45] mame1: current as in trunk or current 1.9.3?<br>
[01:16:00] because matz again prefered not only Array#uniq but also other Array methods to return the original class rather than Array<br>
[01:16:04] current trunk<br>
[01:16:35] iow your r39004 is accepted :-)<br>
=end</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360412013-02-08T14:25:13Zshugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li><li><strong>Assignee</strong> changed from <i>Anonymous</i> to <i>mame (Yusuke Endoh)</i></li></ul><p>I believe r39004 should be reverted.</p>
<p>Matz said "If a method is originally defined in Enumerable, i.e. its return value (Array) is a collection of values from enumerable." at <a href="http://bugs.ruby-lang.org/issues/4136#note-7" class="external">http://bugs.ruby-lang.org/issues/4136#note-7</a>.<br>
However, Array#sort returns an instance of a subclass of Array, by r39004.</p>
<p>$ ./ruby -ve 'class Foo < Array; end; p Foo[2,1,3].sort.class'<br>
ruby 2.0.0dev (2013-02-08 trunk 39154) [i686-linux]<br>
Foo</p>
<p>I'm not sure Matz is right. What should Array#uniq return if Enumerable#uniq is added in the future?</p>
<p>Anyway, there is no enough time to discuss details, so r39004 should be reverted.<br>
Haste makes waste.<br>
If this issue is regarded as a bug, not as a spec change, it can be fixed after the release of 2.0.0.</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360442013-02-08T15:56:42Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li></ul><p>Stated as the maintainer of 1.9.3, +1 to shugo.</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360492013-02-08T19:53:00Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/12">@shugo (Shugo Maeda)</a><br>
Okay, I agree with reverting r39004. Sorry for my poor decision.</p>
<p>@charliesome<br>
Sorry for confusing you. Please commit it again after I create ruby_2_0_0 branch.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360502013-02-08T19:58:37Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>This issue was solved with changeset r39157.<br>
Roman, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>array.c (rb_ary_dup): reverted r39004. see [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Inherited Array class missing (Closed)" href="https://redmine.ruby-lang.org/issues/7768">#7768</a>], and the<br>
release manager finailly decided to revert it.</li>
</ul> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360522013-02-08T19:59:38Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>2.6</i></li></ul> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=360572013-02-08T23:51:46Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>mame (Yusuke Endoh)</i> to <i>Anonymous</i></li></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/9">@usa (Usaku NAKAMURA)</a><br>
Thank you!</p>
<p>@charliesome<br>
I think that it is a good idea to fix only Array#uniq first.<br>
Then, if you want to change other Array methods, please ask matz.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=544312015-10-12T13:32:44Zblazeeboy (Emad Elsaid)blazeeboy@gmail.com
<ul></ul><p>Charlie Somerville wrote:</p>
<blockquote>
<p>=begin<br>
Looks like a regression introduced in r26987<br>
=end</p>
</blockquote>
<p>This Bug stil exists in my current ruby version</p>
<blockquote>
<p>ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]</p>
</blockquote>
<p>and had to make this workaround in my custom class</p>
<blockquote>
<p>class Custom < Array<br>
def uniq<br>
return self if empty?<br>
super<br>
end<br>
end</p>
</blockquote> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=796472019-07-15T21:07:57Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>File</strong> <a href="/attachments/7905">array-uniq-subclass-instance.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/7905/array-uniq-subclass-instance.patch">array-uniq-subclass-instance.patch</a> added</li></ul><p>mame (Yusuke Endoh) wrote:</p>
<blockquote>
<p>I think that it is a good idea to fix only Array#uniq first.</p>
</blockquote>
<p>Looks like Array#uniq was never fixed. It still returns Array instance if length <= 1 and subclass instance otherwise. Attached is a patch that fixes this issue.</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=802522019-07-30T07:29:31Zko1 (Koichi Sasada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/80252/diff?detail_id=53967">diff</a>)</li><li><strong>Assignee</strong> changed from <i>Anonymous</i> to <i>matz (Yukihiro Matsumoto)</i></li></ul> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=813422019-09-02T06:17:42Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p><code>Array#uniq</code> should be fixed.</p>
<p>Matz.</p> Ruby master - Bug #7768: Inherited Array class missinghttps://redmine.ruby-lang.org/issues/7768?journal_id=813672019-09-02T22:19:28Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Fixed by <a href="https://github.com/ruby/ruby/commit/1994adf938afcdc562f87497156e6d4900f3f06b" class="external">https://github.com/ruby/ruby/commit/1994adf938afcdc562f87497156e6d4900f3f06b</a>.</p>