# Buggy code
def visit_call_expr(self, expr: CallExpr) -> None:
    """Analyze a call expression.

    Some call expressions are recognized as special forms, including
    cast(...).
    """
    if expr.analyzed:
        return
    expr.callee.accept(self)
    if refers_to_fullname(expr.callee, "typing.cast"):
        # Special form cast(...).
        if not self.check_fixed_args(expr, 2, "cast"):
            return
        # Translate first argument to an unanalyzed type.
        try:
            target = expr_to_unanalyzed_type(expr.args[0])
        except TypeTranslationError:
            self.fail("Cast target is not a type", expr)
            return
        # Piggyback CastExpr object to the CallExpr object; it takes
        # precedence over the CallExpr semantics.
        expr.analyzed = CastExpr(expr.args[1], target)
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.reveal_type"):
        if not self.check_fixed_args(expr, 1, "reveal_type"):
            return
        expr.analyzed = RevealExpr(kind=REVEAL_TYPE, expr=expr.args[0])
        expr.analyzed.line = expr.line
        expr.analyzed.column = expr.column
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.reveal_locals"):
        # Store the local variable names into the RevealExpr for use in the
        # type checking pass
        local_nodes = []  # type: List[Var]
        if self.is_module_scope():
            # try to determine just the variable declarations in module scope
            # self.globals.values() contains SymbolTableNode's
            # Each SymbolTableNode has an attribute node that is nodes.Var
            # look for variable nodes that marked as is_inferred
            # Each symboltable node has a Var node as .node
            local_nodes = cast(
                List[Var],
                [
                    n.node
                    for name, n in self.globals.items()
                    if getattr(n.node, "is_inferred", False)
                ],
            )
        elif self.is_class_scope():
            # type = None  # type: Optional[TypeInfo]
            if self.type is not None:
                local_nodes = cast(
                    List[Var], [st.node for st in self.type.names.values()]
                )
        elif self.is_func_scope():
            # locals = None  # type: List[Optional[SymbolTable]]
            if self.locals is not None:
                symbol_table = self.locals[-1]
                if symbol_table is not None:
                    local_nodes = cast(
                        List[Var], [st.node for st in symbol_table.values()]
                    )
        expr.analyzed = RevealExpr(kind=REVEAL_LOCALS, local_nodes=local_nodes)
        expr.analyzed.line = expr.line
        expr.analyzed.column = expr.column
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "typing.Any"):
        # Special form Any(...) no longer supported.
        self.fail("Any(...) is no longer supported. Use cast(Any, ...) instead", expr)
    elif refers_to_fullname(expr.callee, "typing._promote"):
        # Special form _promote(...).
        if not self.check_fixed_args(expr, 1, "_promote"):
            return
        # Translate first argument to an unanalyzed type.
        try:
            target = expr_to_unanalyzed_type(expr.args[0])
        except TypeTranslationError:
            self.fail("Argument 1 to _promote is not a type", expr)
            return
        expr.analyzed = PromoteExpr(target)
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.dict"):
        expr.analyzed = self.translate_dict_call(expr)
    elif refers_to_fullname(expr.callee, "builtins.divmod"):
        if not self.check_fixed_args(expr, 2, "divmod"):
            return
        expr.analyzed = OpExpr("divmod", expr.args[0], expr.args[1])
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    else:
        # Normal call expression.
        for a in expr.args:
            a.accept(self)

        if (
            isinstance(expr.callee, MemberExpr)
            and isinstance(expr.callee.expr, NameExpr)
            and expr.callee.expr.name == "__all__"
            and expr.callee.expr.kind == GDEF
            and expr.callee.name in ("append", "extend")
        ):
            if expr.callee.name == "append" and expr.args:
                self.add_exports(expr.args[0])
            elif (
                expr.callee.name == "extend"
                and expr.args
                and isinstance(expr.args[0], (ListExpr, TupleExpr))
            ):
                self.add_exports(expr.args[0].items)


# Traceback (AttributeError)
Traceback (most recent call last):
File ".../bin/mypy", line 11, in <module>
sys.exit(console_entry())
File ".../lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File ".../lib/python3.6/site-packages/mypy/main.py", line 92, in main
res = build.build(sources, options, None, flush_errors, fscache)
File ".../lib/python3.6/site-packages/mypy/build.py", line 155, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache)
File ".../lib/python3.6/site-packages/mypy/build.py", line 204, in _build
graph = dispatch(sources, manager)
File ".../lib/python3.6/site-packages/mypy/build.py", line 2172, in dispatch
process_graph(graph, manager)
File ".../lib/python3.6/site-packages/mypy/build.py", line 2469, in process_graph
process_stale_scc(graph, scc, manager)
File ".../lib/python3.6/site-packages/mypy/build.py", line 2592, in process_stale_scc
graph[id].type_check_first_pass()
File ".../lib/python3.6/site-packages/mypy/build.py", line 1730, in type_check_first_pass
self.type_checker().check_first_pass()
File ".../lib/python3.6/site-packages/mypy/checker.py", line 282, in check_first_pass
self.accept(d)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
stmt.accept(self)
File ".../lib/python3.6/site-packages/mypy/nodes.py", line 845, in accept
return visitor.visit_class_def(self)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 1536, in visit_class_def
self.accept(defn.defs)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
stmt.accept(self)
File ".../lib/python3.6/site-packages/mypy/nodes.py", line 910, in accept
return visitor.visit_block(self)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 1688, in visit_block
self.accept(s)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
stmt.accept(self)
File ".../lib/python3.6/site-packages/mypy/nodes.py", line 925, in accept
return visitor.visit_expression_stmt(self)
File ".../lib/python3.6/site-packages/mypy/checker.py", line 2602, in visit_expression_stmt
self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 3003, in accept
typ = self.visit_call_expr(node, allow_none_return=True)
File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 228, in visit_call_expr
return self.accept(e.analyzed, self.type_context[-1])
File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 3007, in accept
typ = node.accept(self)
File ".../lib/python3.6/site-packages/mypy/nodes.py", line 1674, in accept
return visitor.visit_reveal_expr(self)
File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 2362, in visit_reveal_expr
} if expr.local_nodes is not None else {}
File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 2361, in <dictcomp>
var_node.name(): var_node.type for var_node in expr.local_nodes
AttributeError: 'TypeInfo' object has no attribute 'type'

# Fixed code
def visit_call_expr(self, expr: CallExpr) -> None:
    """Analyze a call expression.

    Some call expressions are recognized as special forms, including
    cast(...).
    """
    if expr.analyzed:
        return
    expr.callee.accept(self)
    if refers_to_fullname(expr.callee, "typing.cast"):
        # Special form cast(...).
        if not self.check_fixed_args(expr, 2, "cast"):
            return
        # Translate first argument to an unanalyzed type.
        try:
            target = expr_to_unanalyzed_type(expr.args[0])
        except TypeTranslationError:
            self.fail("Cast target is not a type", expr)
            return
        # Piggyback CastExpr object to the CallExpr object; it takes
        # precedence over the CallExpr semantics.
        expr.analyzed = CastExpr(expr.args[1], target)
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.reveal_type"):
        if not self.check_fixed_args(expr, 1, "reveal_type"):
            return
        expr.analyzed = RevealExpr(kind=REVEAL_TYPE, expr=expr.args[0])
        expr.analyzed.line = expr.line
        expr.analyzed.column = expr.column
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.reveal_locals"):
        # Store the local variable names into the RevealExpr for use in the
        # type checking pass
        local_nodes = []  # type: List[Var]
        if self.is_module_scope():
            # try to determine just the variable declarations in module scope
            # self.globals.values() contains SymbolTableNode's
            # Each SymbolTableNode has an attribute node that is nodes.Var
            # look for variable nodes that marked as is_inferred
            # Each symboltable node has a Var node as .node
            local_nodes = [
                n.node
                for name, n in self.globals.items()
                if getattr(n.node, "is_inferred", False) and isinstance(n.node, Var)
            ]
        elif self.is_class_scope():
            # type = None  # type: Optional[TypeInfo]
            if self.type is not None:
                local_nodes = [
                    st.node
                    for st in self.type.names.values()
                    if isinstance(st.node, Var)
                ]
        elif self.is_func_scope():
            # locals = None  # type: List[Optional[SymbolTable]]
            if self.locals is not None:
                symbol_table = self.locals[-1]
                if symbol_table is not None:
                    local_nodes = [
                        st.node
                        for st in symbol_table.values()
                        if isinstance(st.node, Var)
                    ]
        expr.analyzed = RevealExpr(kind=REVEAL_LOCALS, local_nodes=local_nodes)
        expr.analyzed.line = expr.line
        expr.analyzed.column = expr.column
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "typing.Any"):
        # Special form Any(...) no longer supported.
        self.fail("Any(...) is no longer supported. Use cast(Any, ...) instead", expr)
    elif refers_to_fullname(expr.callee, "typing._promote"):
        # Special form _promote(...).
        if not self.check_fixed_args(expr, 1, "_promote"):
            return
        # Translate first argument to an unanalyzed type.
        try:
            target = expr_to_unanalyzed_type(expr.args[0])
        except TypeTranslationError:
            self.fail("Argument 1 to _promote is not a type", expr)
            return
        expr.analyzed = PromoteExpr(target)
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    elif refers_to_fullname(expr.callee, "builtins.dict"):
        expr.analyzed = self.translate_dict_call(expr)
    elif refers_to_fullname(expr.callee, "builtins.divmod"):
        if not self.check_fixed_args(expr, 2, "divmod"):
            return
        expr.analyzed = OpExpr("divmod", expr.args[0], expr.args[1])
        expr.analyzed.line = expr.line
        expr.analyzed.accept(self)
    else:
        # Normal call expression.
        for a in expr.args:
            a.accept(self)

        if (
            isinstance(expr.callee, MemberExpr)
            and isinstance(expr.callee.expr, NameExpr)
            and expr.callee.expr.name == "__all__"
            and expr.callee.expr.kind == GDEF
            and expr.callee.name in ("append", "extend")
        ):
            if expr.callee.name == "append" and expr.args:
                self.add_exports(expr.args[0])
            elif (
                expr.callee.name == "extend"
                and expr.args
                and isinstance(expr.args[0], (ListExpr, TupleExpr))
            ):
                self.add_exports(expr.args[0].items)