bugfix: cycle analysis needs to take inheritance into account
This commit is contained in:
parent
fcd91a0cd6
commit
776920dc71
1 changed files with 5 additions and 3 deletions
|
|
@ -322,7 +322,7 @@ proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool =
|
||||||
var t = skipTypes(typ, abstractInst)
|
var t = skipTypes(typ, abstractInst)
|
||||||
if tfAcyclic in t.flags: return
|
if tfAcyclic in t.flags: return
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyArrayConstr, tyOpenArray:
|
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyArrayConstr, tyOpenArray:
|
||||||
if not ContainsOrIncl(marker, t.id):
|
if not ContainsOrIncl(marker, t.id):
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in countup(0, sonsLen(t) - 1):
|
||||||
result = canFormAcycleAux(marker, t.sons[i], startId)
|
result = canFormAcycleAux(marker, t.sons[i], startId)
|
||||||
|
|
@ -330,8 +330,10 @@ proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool =
|
||||||
if t.n != nil: result = canFormAcycleNode(marker, t.n, startId)
|
if t.n != nil: result = canFormAcycleNode(marker, t.n, startId)
|
||||||
else:
|
else:
|
||||||
result = t.id == startId
|
result = t.id == startId
|
||||||
else:
|
if t.kind == tyObject and tfFinal notin t.flags:
|
||||||
nil
|
# damn inheritance may introduce cycles:
|
||||||
|
result = true
|
||||||
|
else: nil
|
||||||
|
|
||||||
proc canFormAcycle(typ: PType): bool =
|
proc canFormAcycle(typ: PType): bool =
|
||||||
# XXX as I expect cycles introduced by closures are very rare, we pretend
|
# XXX as I expect cycles introduced by closures are very rare, we pretend
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue