Project

General

Profile

Bug #12684

Delegator#eql? missing

Added by carsonreinke (Carson Reinke) over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:76950]

Description

There is some strange behavior because Delegator is missing an alias of #eql? to #==

2.3.1 :001 > s = 'test'
 => "test" 
2.3.1 :002 > d = SimpleDelegator.new(s)
 => "test" 
2.3.1 :003 > d.eql?(d)
 => false 
2.3.1 :004 > d == d
 => true 
2.3.1 :005 > d.hash == d.hash
 => true

I understand that Delegator is a BasicObject and that does not define #eql? method, but this method is being used by Arrayr.

For example,

2.3.1 :001 > s = 'test'
 => "test" 
2.3.1 :002 > a = [SimpleDelegator.new(s), SimpleDelegator.new(s)]
 => ["test", "test"] 
2.3.1 :003 > a[0] == a[1]
 => true 
2.3.1 :004 > a.uniq()
 => ["test", "test"]
2.3.1 :005 > a[0].hash == a[1].hash
 => true

Kind of strange behavior, especially reading the documentation.

Now maybe, Array#uniq should be changed to use #== instead of #eql?

Associated revisions

Revision 3c45a789
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Delegate to eql? [Fix GH-1564]

  • lib/delegate.rb (eql?): Delegate to eql? of the inner object. based on the patch by giginet giginet.net@gmail.com. [ruby-core:76950] [Bug #12684]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59167
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Delegate to eql? [Fix GH-1564]

  • lib/delegate.rb (eql?): Delegate to eql? of the inner object. based on the patch by giginet giginet.net@gmail.com. [ruby-core:76950] [Bug #12684]

Revision 59167
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Delegate to eql? [Fix GH-1564]

  • lib/delegate.rb (eql?): Delegate to eql? of the inner object. based on the patch by giginet giginet.net@gmail.com. [ruby-core:76950] [Bug #12684]

Revision 59167
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Delegate to eql? [Fix GH-1564]

  • lib/delegate.rb (eql?): Delegate to eql? of the inner object. based on the patch by giginet giginet.net@gmail.com. [ruby-core:76950] [Bug #12684]

Revision d389625a
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Added version guards [Bug #12684]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59168
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Added version guards [Bug #12684]

Revision 59168
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Added version guards [Bug #12684]

Revision 59168
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

Added version guards [Bug #12684]

History

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED
  • Description updated (diff)

Seems fine.

Updated by ko1 (Koichi Sasada) almost 2 years ago

  • Assignee set to nobu (Nobuyoshi Nakada)

Updated by Eregon (Benoit Daloze) almost 2 years ago

nobu (Nobuyoshi Nakada) Any update on this? I think your patch is OK.

#5

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59167.


Delegate to eql? [Fix GH-1564]

  • lib/delegate.rb (eql?): Delegate to eql? of the inner object. based on the patch by giginet giginet.net@gmail.com. [ruby-core:76950] [Bug #12684]

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: WONTFIX

I think this is a spec change because of existence of the test in rubyspec about this behavior.
I will change WONTFIX for 2.4. Please tell us if there are any real world application suffered with this issue.

Also available in: Atom PDF