Fix inconsistencies with Time{WithZone}#{hash,eql?} #3725
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If
foo.eql?(bar)
returnstrue
then so shouldbar.eql?(foo)
.Moreover,
foo.hash
must then be the same asbar.hash
.Otherwise the Hash lookup will fail.
TimeWithZone
wants to act like aTime
, but currently:This pull request fixes this. Since
TimeWithZone
wants to be freely replaceable with aTime
:There is also a problem with DateTime vs TimeWithZone:
Since
DateTime
and aTime
are both builtin classes and that aTime
is nevereql?
to aDateTime
or vice-versa (as per the doc and the implementation), the patch also insures that aTimeWithZone
can no longer beeql?
to aDateTime
:Thanks
Extended discussion at #905