[bugfix] hashes: fix regression for nested containers (#11426)

Move forward declarations earlier.
This commit is contained in:
Miran 2019-06-08 00:34:11 +02:00 • committed by Andreas Rumpf
commit bf9f1f7b45

View file

@ -149,6 +149,12 @@ proc hash*(x: float): Hash {.inline.} =
var y = x + 1.0 var y = x + 1.0
result = cast[ptr Hash](addr(y))[] result = cast[ptr Hash](addr(y))[]
# Forward declarations before methods that hash containers. This allows
# containers to contain other containers
proc hash*[A](x: openArray[A]): Hash
proc hash*[A](x: set[A]): Hash
template bytewiseHashing(result: Hash, x: typed, start, stop: int) = template bytewiseHashing(result: Hash, x: typed, start, stop: int) =
for i in start .. stop: for i in start .. stop:
result = result !& hash(x[i]) result = result !& hash(x[i])
@ -292,12 +298,6 @@ proc hashIgnoreCase*(sBuf: string, sPos, ePos: int): Hash =
result = !$h result = !$h
# Forward declarations before methods that hash containers. This allows
# containers to contain other containers
proc hash*[A](x: openArray[A]): Hash
proc hash*[A](x: set[A]): Hash
proc hash*[T: tuple](x: T): Hash = proc hash*[T: tuple](x: T): Hash =
## Efficient hashing of tuples. ## Efficient hashing of tuples.
for f in fields(x): for f in fields(x):