Skip to content

Commit

Permalink
add missing hash method for QuoteNode
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 23, 2015
1 parent d88dd21 commit a6f1ee2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ else
hash(x::Expr, h::UInt) = hash(x.args, hash(x.head, h + 0x96d26dc6))
end

hash(x::QuoteNode, h::UInt) = hash(x.value, hash(QuoteNode, h))

# hashing ranges by component at worst leads to collisions for very similar ranges
const hashr_seed = UInt === UInt64 ? 0x80707b6821b70087 : 0x21b70087
Expand Down
4 changes: 4 additions & 0 deletions test/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ x = sprand(10, 10, 0.5)
x[1] = 1
x.nzval[1] = 0
@test hash(x) == hash(full(x))

let a = QuoteNode(1), b = QuoteNode(1.0)
@test (hash(a)==hash(b)) == (a==b)
end

0 comments on commit a6f1ee2

Please sign in to comment.