Hash nil embedded pointers
This commit is contained in:
parent
0c4ef8269f
commit
7187a45f9c
|
@ -223,7 +223,7 @@ proc cannonicalize*[E](pr: var Preserve[E]) =
|
|||
else:
|
||||
discard
|
||||
|
||||
proc hash*(pr: Preserve): Hash =
|
||||
proc hash*[E](pr: Preserve[E]): Hash =
|
||||
## Produce a `Hash` of `pr` for use with a `HashSet` or `Table`.
|
||||
var h = hash(pr.kind.int) !& hash(pr.embedded)
|
||||
case pr.kind
|
||||
|
@ -254,7 +254,13 @@ proc hash*(pr: Preserve): Hash =
|
|||
for (key, val) in pr.dict.items:
|
||||
h = h !& hash(key) !& hash(val)
|
||||
of pkEmbedded:
|
||||
when E is void:
|
||||
h = h !& hash(pr.embed)
|
||||
else:
|
||||
if pr.embed.isNil:
|
||||
h = h !& hash(false)
|
||||
else:
|
||||
h = h !& hash(pr.embed)
|
||||
!$h
|
||||
|
||||
proc `[]`*(pr: Preserve; i: int): Preserve =
|
||||
|
|
Loading…
Reference in New Issue