forked from M-Labs/artiq
compiler.types: fix TVar.find() for very large paths.
This commit is contained in:
parent
00164390a1
commit
bf1a583fda
|
@ -60,8 +60,18 @@ class TVar(Type):
|
|||
if self.parent is self:
|
||||
return self
|
||||
else:
|
||||
root = self.parent.find()
|
||||
self.parent = root # path compression
|
||||
# The recursive find() invocation is turned into a loop
|
||||
# because paths resulting from unification of large arrays
|
||||
# can easily cause a stack overflow.
|
||||
root = self
|
||||
while isinstance(root, TVar):
|
||||
if root is root.parent:
|
||||
break
|
||||
else:
|
||||
root = root.parent
|
||||
|
||||
# path compression
|
||||
self.parent = root
|
||||
return root
|
||||
|
||||
def unify(self, other):
|
||||
|
|
Loading…
Reference in New Issue