Project

General

Profile

Actions

Bug #14263

closed

Array Intersection does not seem to use hash

Added by gkellogg (Gregg Kellogg) over 6 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:84573]

Description

According to the documentation for Array#&, comparison is done using hash and eql? However, this does not seem to be the case in 2.5.0.

If two instances are .eql? but their hashes are not, an array & should be empty:

([Var.new('a')] & [Var.new('b')]).empty?

This test works in 2.4.2 (and all earlier versions), but fails in 2.5.0. See attached script.


Files

array_intersection.rb (535 Bytes) array_intersection.rb Failing array intersection test gkellogg (Gregg Kellogg), 12/31/2017 09:58 PM
test-14264.rb (956 Bytes) test-14264.rb styrmis (Stefan Magnuson), 03/21/2018 02:13 PM
array-eql-by-hash.patch (2.09 KB) array-eql-by-hash.patch Patch to compare by hash in Array set operations for all array sizes styrmis (Stefan Magnuson), 03/25/2018 09:38 PM
object-eql-documentation-tweak.patch (825 Bytes) object-eql-documentation-tweak.patch Patch to documentation for Object#eql? to add warning regarding hash equality styrmis (Stefan Magnuson), 03/25/2018 09:38 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14573: rb_ary_or doesn't check objects hash when the array contains less than SMALL_ARRAY_LENClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0