[red-knot] visit with-item vars even if not a Name (#13409)

This fixes the last panic on checking pandas.

(Match statement became an `if let` because clippy decided it wanted
that once I added the additional line in the else case?)

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Carl Meyer 2024-09-19 10:37:49 -07:00 committed by GitHub
parent f110d80279
commit 260c2ecd15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View file

@ -926,14 +926,13 @@ impl<'db> TypeInferenceBuilder<'db> {
} = with_statement;
for item in items {
match item.optional_vars.as_deref() {
Some(ast::Expr::Name(name)) => {
self.infer_definition(name);
}
_ => {
// TODO infer definitions in unpacking assignment
self.infer_expression(&item.context_expr);
}
let target = item.optional_vars.as_deref();
if let Some(ast::Expr::Name(name)) = target {
self.infer_definition(name);
} else {
// TODO infer definitions in unpacking assignment
self.infer_expression(&item.context_expr);
self.infer_optional_expression(target);
}
}

View file

@ -0,0 +1,2 @@
with foo() as self.bar:
pass