Skip to content

Commit 48373f5

Browse files
committed
misc: Fix FindWithin
1 parent 528d8f5 commit 48373f5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

devito/ir/iet/visitors.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ def __init__(self, match: type, start: Node, stop: Node | None = None) -> None:
11411141

11421142
def _post_visit(self, ret: Iterator[Node]) -> list[Node]:
11431143
ret = super()._post_visit(ret)
1144-
if ret[-1] is self.STOP:
1144+
if ret and ret[-1] is self.STOP:
11451145
ret.pop()
11461146
return ret
11471147

@@ -1151,13 +1151,15 @@ def visit_Node(self, o: Node, flag: bool = False) -> Iterator[Node]:
11511151

11521152
if flag and self.rule(self.match, o):
11531153
yield o
1154-
for i in o.children:
1155-
for r in self._visit(i, flag=flag):
1156-
yield r
1157-
if r is self.STOP:
1154+
for child in o.children:
1155+
for i in self._visit(child, flag=flag):
1156+
if flag and i is self.STOP:
1157+
yield self.STOP
11581158
return
11591159

1160-
if o is self.stop:
1160+
yield i
1161+
1162+
if flag and o is self.stop:
11611163
yield self.STOP
11621164

11631165

0 commit comments

Comments
 (0)