From bc80b3d190b9aaca5514f28aab94a2cb33937b26 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 27 Jun 2013 01:18:32 -0500 Subject: Fix some #eql? correctness issues The implementation of #eql? and #hash should ensure that if a.eql?(b), then a.hash == b.hash, but #eql? itself should not *depend* on #hash. For example, given class Thingy def eql? instance_of?(other.class) && hash == other.hash end def hash [name, *tags].hash end end if #hash produces a collision for different values of [name, *tags], two Thingy objects will appear to be eql?, even though this is not the case. Instead, #eql? should depend on the equality of name and tags directly. --- Library/Homebrew/options.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/options.rb') diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb index c7d1acca2..b59cd2930 100644 --- a/Library/Homebrew/options.rb +++ b/Library/Homebrew/options.rb @@ -20,7 +20,7 @@ class Option end def eql?(other) - other.is_a?(self.class) && hash == other.hash + instance_of?(other.class) && name == other.name end def hash -- cgit v1.2.3