mirror of https://github.com/astral-sh/ruff
[ty] Fix panic when pulling types for `UnaryOp` expressions inside `Literal` slices (#18536)
This commit is contained in:
parent
95497ffaab
commit
72552f31e4
|
|
@ -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: ...
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue