Skip to content

Commit 9b0ec61

Browse files
committed
fix
1 parent 82106db commit 9b0ec61

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mypy/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,11 @@ def accept_loop(
607607
"""
608608
# The outer frame accumulates the results of all iterations
609609
with self.binder.frame_context(can_skip=False, conditional_frame=True):
610-
partials_old = len(self.partial_types[0].map)
610+
partials_old = sum(len(pts.map) for pts in self.partial_types)
611611
while True:
612612
with self.binder.frame_context(can_skip=True, break_frame=2, continue_frame=1):
613613
self.accept(body)
614-
partials_new = len(self.partial_types[0].map)
614+
partials_new = sum(len(pts.map) for pts in self.partial_types)
615615
if (partials_new == partials_old) and not self.binder.last_pop_changed:
616616
break
617617
partials_old = partials_new

test-data/unit/check-narrowing.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,4 +2379,13 @@ def g() -> None:
23792379
z[0] + "v" # E: Unsupported operand types for + ("int" and "str")
23802380
z.append(1)
23812381

2382+
class A:
2383+
def g(self) -> None:
2384+
z = [] # E: Need type annotation for "z" (hint: "z: List[<type>] = ...")
2385+
for i in range(2):
2386+
while f():
2387+
if z:
2388+
z[0] + "v" # E: Unsupported operand types for + ("int" and "str")
2389+
z.append(1)
2390+
23822391
[builtins fixtures/primitives.pyi]

0 commit comments

Comments
 (0)