# Buggy code
def accept_loop(self, body: Union[IfStmt, Block], else_body: Block = None) -> Type:
    """Repeatedly type check a loop body until the frame doesn't change.

    Then check the else_body.
    """
    # The outer frame accumulates the results of all iterations
    with self.binder.frame_context(1) as outer_frame:
        self.binder.push_loop_frame()
        while True:
            with self.binder.frame_context(1):
                # We may skip each iteration
                self.binder.options_on_return[-1].append(outer_frame)
                self.accept(body)
            if not self.binder.last_pop_changed:
                break
        self.binder.pop_loop_frame()
        if else_body:
            self.accept(else_body)


# Traceback (AttributeError)
Traceback (most recent call last):
File "./scripts/mypy", line 6, in <module>
main(__file__)
File "mypy/mypy/main.py", line 50, in main
type_check_only(sources, bin_dir, options)
File "mypy/mypy/main.py", line 94, in type_check_only
python_path=options.python_path)
File "mypy/mypy/build.py", line 210, in build
result = manager.process(initial_states)
File "mypy/mypy/build.py", line 425, in process
next.process()
File "mypy/mypy/build.py", line 930, in process
self.type_checker().visit_file(self.tree, self.tree.path)
File "mypy/mypy/checker.py", line 409, in visit_file
self.accept(d)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 707, in accept
return visitor.visit_try_stmt(self)
File "mypy/mypy/checker.py", line 1732, in visit_try_stmt
self.accept(s.else_body)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 526, in accept
return visitor.visit_block(self)
File "mypy/mypy/checker.py", line 1113, in visit_block
self.accept(s)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 382, in accept
return visitor.visit_func_def(self)
File "mypy/mypy/checker.py", line 594, in visit_func_def
'redefinition with type')
File "mypy/mypy/checker.py", line 2117, in check_subtype
if not is_subtype(subtype, supertype):
File "mypy/mypy/subtypes.py", line 49, in is_subtype
return left.accept(SubtypeVisitor(right, type_parameter_checker))
AttributeError: 'NoneType' object has no attribute 'accept'

# Fixed code
def accept_loop(
    self,
    body: Statement,
    else_body: Statement = None,
    *,
    exit_condition: Expression = None,
) -> Type:
    """Repeatedly type check a loop body until the frame doesn't change.
    If exit_condition is set, assume it must be False on exit from the loop.

    Then check the else_body.
    """
    # The outer frame accumulates the results of all iterations
    with self.binder.frame_context(can_skip=False):
        while True:
            with self.binder.frame_context(
                can_skip=True, break_frame=2, continue_frame=1
            ):
                self.accept(body)
            if not self.binder.last_pop_changed:
                break
        if exit_condition:
            _, else_map = self.find_isinstance_check(exit_condition)
            self.push_type_map(else_map)
        if else_body:
            self.accept(else_body)