diff --git a/crates/ty_python_semantic/resources/mdtest/annotations/literal.md b/crates/ty_python_semantic/resources/mdtest/annotations/literal.md index 0c266868e1..3bd9e54c85 100644 --- a/crates/ty_python_semantic/resources/mdtest/annotations/literal.md +++ b/crates/ty_python_semantic/resources/mdtest/annotations/literal.md @@ -60,6 +60,10 @@ class NotAnEnum: # error: [invalid-type-form] invalid5: Literal[NotAnEnum.x] + +a_list: list[int] = [1, 2, 3] +# error: [invalid-type-form] +invalid6: Literal[a_list[0]] ``` ## Shortening unions of literals diff --git a/crates/ty_python_semantic/src/types/infer.rs b/crates/ty_python_semantic/src/types/infer.rs index 17644cc2f9..0f9733fafc 100644 --- a/crates/ty_python_semantic/src/types/infer.rs +++ b/crates/ty_python_semantic/src/types/infer.rs @@ -10438,6 +10438,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { self.store_expression_type(parameters, ty); ty } else { + self.infer_expression(slice); self.store_expression_type(parameters, Type::unknown()); return Err(vec![parameters]);