fix for Issue #626 - Distinct and generics not working together
This commit is contained in:
parent
40b379859c
commit
01e43fbe83
1 changed files with 6 additions and 2 deletions
|
|
@ -622,6 +622,8 @@ proc initSameTypeClosure: TSameTypeClosure =
|
||||||
# we do the initialization lazily for performance (avoids memory allocations)
|
# we do the initialization lazily for performance (avoids memory allocations)
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc containsOrIncl(c: var TSameTypeClosure, a, b: PType): bool =
|
proc containsOrIncl(c: var TSameTypeClosure, a, b: PType): bool =
|
||||||
result = not IsNil(c.s) and c.s.contains((a.id, b.id))
|
result = not IsNil(c.s) and c.s.contains((a.id, b.id))
|
||||||
if not result:
|
if not result:
|
||||||
|
|
@ -754,6 +756,8 @@ proc sameObjectTypes*(a, b: PType): bool =
|
||||||
var c = initSameTypeClosure()
|
var c = initSameTypeClosure()
|
||||||
result = sameTypeAux(a, b, c)
|
result = sameTypeAux(a, b, c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc sameDistinctTypes*(a, b: PType): bool {.inline.} =
|
proc sameDistinctTypes*(a, b: PType): bool {.inline.} =
|
||||||
result = sameObjectTypes(a, b)
|
result = sameObjectTypes(a, b)
|
||||||
|
|
||||||
|
|
@ -837,7 +841,7 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
result = sameObjectStructures(a, b, c) and sameFlags(a, b)
|
result = sameObjectStructures(a, b, c) and sameFlags(a, b)
|
||||||
of tyDistinct:
|
of tyDistinct:
|
||||||
CycleCheck()
|
CycleCheck()
|
||||||
if c.cmp == dcEq: result = sameDistinctTypes(a, b) and sameFlags(a, b)
|
if c.cmp == dcEq: result = sameTypeAux(a, b, c) and sameFlags(a, b)
|
||||||
else: result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b)
|
else: result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b)
|
||||||
of tyEnum, tyForward, tyProxy:
|
of tyEnum, tyForward, tyProxy:
|
||||||
# XXX generic enums do not make much sense, but require structural checking
|
# XXX generic enums do not make much sense, but require structural checking
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue