You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thread '<unnamed>' panicked at crates/red_knot_python_semantic/src/types/infer.rs:872:37:
no entry found for key
stack backtrace:
[…]
6: red_knot_python_semantic::semantic_index::SemanticIndex::definition
at ./crates/red_knot_python_semantic/src/semantic_index.rs:210:33
7: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_definition
at ./crates/red_knot_python_semantic/src/types/infer.rs:872:26
8: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_type_parameters
at ./crates/red_knot_python_semantic/src/types/infer.rs:4036:50
9: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_type_alias_statement
at ./crates/red_knot_python_semantic/src/types/infer.rs:1805:13
10: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_statement
at ./crates/red_knot_python_semantic/src/types/infer.rs:851:53
11: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_body
at ./crates/red_knot_python_semantic/src/types/infer.rs:831:13
12: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_module
at ./crates/red_knot_python_semantic/src/types/infer.rs:793:9
13: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region_scope
at ./crates/red_knot_python_semantic/src/types/infer.rs:417:17
14: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region
at ./crates/red_knot_python_semantic/src/types/infer.rs:405:46
15: red_knot_python_semantic::types::infer::TypeInferenceBuilder::finish
at ./crates/red_knot_python_semantic/src/types/infer.rs:4044:9
The text was updated successfully, but these errors were encountered:
## Summary
This avoids a panic inside `TypeInferenceBuilder::infer_type_parameters`
when encountering generic type aliases:
```py
type ListOrSet[T] = list[T] | set[T]
```
To fix this properly, we would have to treat type aliases as being their own
annotation scope [1]. The left hand side is a definition for the type parameter
`T` which is being used in the special annotation scope on the right hand side.
Similar to how it works for generic functions and classes.
[1] https://docs.python.org/3/reference/compound_stmts.html#generic-type-aliasescloses#14307
## Test Plan
Added new example to the corpus.
Red knot currently panics when encountering PEP-695 generic type aliases:
Backtrace:
The text was updated successfully, but these errors were encountered: