Skip to content

Commit 52b94f9

Browse files
committed
Update Builder.py
1 parent d613cbc commit 52b94f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

edg/core/Builder.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ def push_element(self, elt: BaseBlock) -> Optional[BaseBlock]:
2222
self.stack.append(elt)
2323
return prev_elt
2424

25-
def pop_to(self, elt: Optional[BaseBlock]) -> None:
26-
if (elt is None and not self.stack) or (elt is not None and self.stack[-1] is elt):
25+
def pop_to(self, prev: Optional[BaseBlock]) -> None:
26+
"""Pops at most one element from stack, expecting prev to be at the top of the stack.
27+
The pattern should be one pop for one push, and allowing that duplicate pushes are ignored."""
28+
if (prev is None and not self.stack) or (prev is not None and self.stack[-1] is prev):
2729
return
2830

2931
self.stack.pop()
30-
assert (elt is None and not self.stack) or (elt is not None and self.stack[-1] is elt)
32+
assert (prev is None and not self.stack) or (prev is not None and self.stack[-1] is prev)
3133

3234
def get_enclosing_block(self) -> Optional[BaseBlock]:
3335
if not self.stack:

0 commit comments

Comments
 (0)