[ruby-core:93797] [Ruby master Bug#7768] Inherited Array class missing

From: merch-redmine@...
Date: 2019-07-15 21:07:57 UTC
List: ruby-core #93797
Issue #7768 has been updated by jeremyevans0 (Jeremy Evans).

File array-uniq-subclass-instance.patch added

mame (Yusuke Endoh) wrote:
> I think that it is a good idea to fix only Array#uniq first.

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.

----------------------------------------
Bug #7768: Inherited Array class missing
https://bugs.ruby-lang.org/issues/7768#change-79647

* Author: england (Roman Ivanilov)
* Status: Assigned
* Priority: Normal
* Assignee: charliesome (Charlie Somerville)
* Target version: 
* ruby -v: 1.9
* Backport: 
----------------------------------------
=begin
Hello. I apologize if I missed something.
I found strange behavior in ruby 1.9:

 class Custom < Array; end
 Custom.new(0){|i| i + 1}.uniq.class # => Array
 Custom.new(2){|i| i + 1}.uniq.class # => Custom

while in 1.8 it works just as I expected. 

 class Custom < Array; end
 Custom.new(0){|i| i + 1}.uniq.class # => Custom
 Custom.new(2){|i| i + 1}.uniq.class # => Custom

* it is actual not only for the uniq method.
* tested with ree-1.8.7-2010.02, ruby-1.9.2-p290, ruby-1.9.3-p375, ruby-1.9.3-p125

Any bug here?

=end

---Files--------------------------------
array-uniq-subclass-instance.patch (2.15 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread