Correctly hash inferred types (#8286)
We don't really want to hash the tyInferred container since that'd make the "real" type and its inferred counterpart produce different hashes and types for the very same type. Fixes #8280
This commit is contained in:
parent
9aad193d27
commit
ba1f036a56
2 changed files with 17 additions and 1 deletions
|
|
@ -163,7 +163,7 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
c.hashType t.sons[i], flags
|
c.hashType t.sons[i], flags
|
||||||
else:
|
else:
|
||||||
c.hashType t.lastSon, flags
|
c.hashType t.lastSon, flags
|
||||||
of tyAlias, tySink, tyUserTypeClasses:
|
of tyAlias, tySink, tyUserTypeClasses, tyInferred:
|
||||||
c.hashType t.lastSon, flags
|
c.hashType t.lastSon, flags
|
||||||
of tyBool, tyChar, tyInt..tyUInt64:
|
of tyBool, tyChar, tyInt..tyUInt64:
|
||||||
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
||||||
|
|
|
||||||
16
tests/concepts/t8280.nim
Normal file
16
tests/concepts/t8280.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
discard """
|
||||||
|
output: "()"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
Iterable[T] = concept x
|
||||||
|
for elem in x:
|
||||||
|
elem is T
|
||||||
|
|
||||||
|
proc max[A](iter: Iterable[A]): A =
|
||||||
|
discard
|
||||||
|
|
||||||
|
type
|
||||||
|
MyType = object
|
||||||
|
|
||||||
|
echo max(@[MyType()])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue