Skip to content

Commit 9d5aebb

Browse files
JuthoJeffBezanson
authored andcommitted
fix hashing of Rational{<:Integer} (fixes #25814) (#25817)
1 parent f11d820 commit 9d5aebb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

base/hashing2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function hash(x::Rational{<:BitInteger64}, h::UInt)
155155
den >>= pow
156156
pow = -pow
157157
if den == 1 && abs(num) < 9007199254740992
158-
return hash(ldexp(Float64(num),pow))
158+
return hash(ldexp(Float64(num),pow),h)
159159
end
160160
end
161161
h = hash_integer(den, h)

test/hashing.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ for T = types[2:end],
3434
x = vals,
3535
a = coerce(T, x)
3636
@test hash(a,zero(UInt)) == invoke(hash, Tuple{Real, UInt}, a, zero(UInt))
37+
@test hash(a,one(UInt)) == invoke(hash, Tuple{Real, UInt}, a, one(UInt))
3738
end
3839

3940
for T = types,

0 commit comments

Comments
 (0)