Skip to content

Commit 57921b5

Browse files
committed
Always clear breaking_out in pop_frame()
It's a bit simpler than doing so if fall_through, and we don't rely on the distinction.
1 parent 66cbaf5 commit 57921b5

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

mypy/checker.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ def pop_frame(self, fall_through: int = 0) -> Frame:
192192

193193
self.last_pop_changed = self.update_from_options(options)
194194
self.last_pop_breaking_out = self.breaking_out
195-
if fall_through:
196-
self.breaking_out = False
195+
self.breaking_out = False
197196

198197
return result
199198

@@ -1692,18 +1691,15 @@ def visit_if_stmt(self, s: IfStmt) -> Type:
16921691

16931692
# Might also want to issue a warning
16941693
# print("Warning: isinstance always true")
1695-
if breaking_out:
1696-
self.binder.breaking_out = True
1697-
return None
16981694
break
16991695
else: # Didn't break => can't prove one of the conditions is always true
17001696
with self.binder.frame_context(2):
17011697
if s.else_body:
17021698
self.accept(s.else_body)
17031699
breaking_out = breaking_out and self.binder.last_pop_breaking_out
1704-
if breaking_out:
1705-
self.binder.breaking_out = True
1706-
return None
1700+
if breaking_out:
1701+
self.binder.breaking_out = True
1702+
return None
17071703

17081704
def visit_while_stmt(self, s: WhileStmt) -> Type:
17091705
"""Type check a while statement."""

0 commit comments

Comments
 (0)