Skip to content

Attempted fix for crash with runtime generics #2309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,11 @@ def visit_reveal_type_expr(self, expr: RevealTypeExpr) -> Type:
def visit_type_application(self, tapp: TypeApplication) -> Type:
"""Type check a type application (expr[type, ...])."""
tp = cast(CallableType, self.accept(tapp.expr))
if isinstance(tp, AnyType):
return AnyType()
if not hasattr(tp, 'variables'):
self.chk.fail('Type application targets invalid expression', tapp)
return AnyType()
return self.apply_generic_arguments(tp, tapp.types, tapp)

def visit_type_alias_expr(self, alias: TypeAliasExpr) -> Type:
Expand Down