File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments