# Buggy code
def visit_if_stmt(self, s: IfStmt) -> Type:
    """Type check an if statement."""
    breaking_out = True
    # This frame records the knowledge from previous if/elif clauses not being taken.
    with self.binder.frame_context():
        for e, b in zip(s.expr, s.body):
            t = self.accept(e)
            self.check_usable_type(t, e)
            if_map, else_map = find_isinstance_check(e, self.type_map)
            if if_map is None:
                # The condition is always false
                # XXX should issue a warning?
                pass
            else:
                # Only type check body if the if condition can be true.
                with self.binder.frame_context(2):
                    if if_map:
                        for var, type in if_map.items():
                            self.binder.push(var, type)

                    self.accept(b)
                breaking_out = breaking_out and self.binder.last_pop_breaking_out

                if else_map:
                    for var, type in else_map.items():
                        self.binder.push(var, type)
            if else_map is None:
                # The condition is always true => remaining elif/else blocks
                # can never be reached.

                # Might also want to issue a warning
                # print("Warning: isinstance always true")
                break
        else:  # Didn't break => can't prove one of the conditions is always true
            with self.binder.frame_context(2):
                if s.else_body:
                    self.accept(s.else_body)
            breaking_out = breaking_out and self.binder.last_pop_breaking_out
    if breaking_out:
        self.binder.breaking_out = True
    return None


# 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 visit_if_stmt(self, s: IfStmt) -> Type:
    """Type check an if statement."""
    # This frame records the knowledge from previous if/elif clauses not being taken.
    # Fall-through to the original frame is handled explicitly in each block.
    with self.binder.frame_context(can_skip=False, fall_through=0):
        for e, b in zip(s.expr, s.body):
            t = self.accept(e)
            self.check_usable_type(t, e)
            if_map, else_map = self.find_isinstance_check(e)

            # XXX Issue a warning if condition is always False?
            with self.binder.frame_context(can_skip=True, fall_through=2):
                self.push_type_map(if_map)
                self.accept(b)

            # XXX Issue a warning if condition is always True?
            self.push_type_map(else_map)

        with self.binder.frame_context(can_skip=False, fall_through=2):
            if s.else_body:
                self.accept(s.else_body)
    return None