diff --git a/crates/ty_project/resources/test/corpus/literal_slices.py b/crates/ty_project/resources/test/corpus/literal_slices.py index 748762c0d1..b1b8ae6fe5 100644 --- a/crates/ty_project/resources/test/corpus/literal_slices.py +++ b/crates/ty_project/resources/test/corpus/literal_slices.py @@ -3,4 +3,4 @@ from typing import Literal class Format: STRING = "string" -def evaluate(format: Literal[Format.STRING]) -> str: ... +def evaluate(a: Literal[Format.STRING], b: Literal[-1]) -> str: ... diff --git a/crates/ty_project/tests/check.rs b/crates/ty_project/tests/check.rs index e42df7228d..ae1ab54cb6 100644 --- a/crates/ty_project/tests/check.rs +++ b/crates/ty_project/tests/check.rs @@ -304,17 +304,8 @@ const KNOWN_FAILURES: &[(&str, bool, bool)] = &[ // These are all "expression should belong to this TypeInference region and TypeInferenceBuilder should have inferred a type for it" ("crates/ty_vendored/vendor/typeshed/stdlib/abc.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/ast.pyi", true, true), ("crates/ty_vendored/vendor/typeshed/stdlib/builtins.pyi", true, true), ("crates/ty_vendored/vendor/typeshed/stdlib/curses/__init__.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/lzma.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/pathlib/__init__.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/pathlib/types.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/pstats.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/socket.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/sqlite3/__init__.pyi", true, true), - ("crates/ty_vendored/vendor/typeshed/stdlib/tempfile.pyi", true, true), ]; /// Attempting to check one of these files causes a stack overflow diff --git a/crates/ty_python_semantic/src/types/infer.rs b/crates/ty_python_semantic/src/types/infer.rs index 4992a3fceb..6650552b1e 100644 --- a/crates/ty_python_semantic/src/types/infer.rs +++ b/crates/ty_python_semantic/src/types/infer.rs @@ -9481,7 +9481,9 @@ impl<'db> TypeInferenceBuilder<'db, '_> { if matches!(u.op, ast::UnaryOp::USub | ast::UnaryOp::UAdd) && u.operand.is_number_literal_expr() => { - self.infer_unary_expression(u) + let ty = self.infer_unary_expression(u); + self.store_expression_type(parameters, ty); + ty } _ => { self.infer_expression(parameters);