Don't return early, since we add patterns to memo before they've been checked

This commit is contained in:
Jan Petykiewicz 2020-07-12 03:50:19 -07:00
parent 0589fbb1b8
commit a4b5776208

View File

@ -913,9 +913,6 @@ class Pattern:
A filtered list in which no pattern is referenced by any other pattern. A filtered list in which no pattern is referenced by any other pattern.
""" """
def get_children(pat: Pattern, memo: Set) -> Set: def get_children(pat: Pattern, memo: Set) -> Set:
if pat in memo:
return memo
children = set(sp.pattern for sp in pat.subpatterns if sp.pattern is not None) children = set(sp.pattern for sp in pat.subpatterns if sp.pattern is not None)
new_children = children - memo new_children = children - memo
memo |= children memo |= children