summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2020-03-18 10:47:46 +0100
committerAraq <rumpf_a@web.de>2020-03-18 10:47:58 +0100
commit3f1a85b7f03a4998f09a4fe6e8bf13672742fcb9 (patch)
treef6c73aebd551b8a1ba9cb3d5083ff486854b90a4
parent5f6997794e1482187decbd074ea274fe32a223d8 (diff)
downloadNim-3f1a85b7f03a4998f09a4fe6e8bf13672742fcb9.tar.gz
fixes hash(HashSet) which was wrong as it didn't respect tombstones; refs #13649
-rw-r--r--lib/pure/collections/sets.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index 9f800e6d1..caa25dbb3 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -574,7 +574,8 @@ proc map*[A, B](data: HashSet[A], op: proc (x: A): B {.closure.}): HashSet[B] =
 proc hash*[A](s: HashSet[A]): Hash =
   ## Hashing of HashSet.
   for h in 0 .. high(s.data):
-    result = result xor s.data[h].hcode
+    if isFilledAndValid(s.data[h].hcode):
+      result = result xor s.data[h].hcode
   result = !$result
 
 proc `$`*[A](s: HashSet[A]): string =