mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
[red-knot] SemanticIndexBuilder
visits value before target in named expressions (#13053)
The `SemanticIndexBuilder` was causing a cycle in a salsa query by attempting to resolve the target before the value in a named expression (e.g. `x := x+1`). This PR swaps the order, avoiding a panic. Closes #13012.
This commit is contained in:
parent
02c4373a49
commit
2edd32aa31
5 changed files with 27 additions and 2 deletions
|
@ -658,11 +658,11 @@ where
|
|||
}
|
||||
ast::Expr::Named(node) => {
|
||||
debug_assert!(self.current_assignment.is_none());
|
||||
self.current_assignment = Some(node.into());
|
||||
// TODO walrus in comprehensions is implicitly nonlocal
|
||||
self.visit_expr(&node.value);
|
||||
self.current_assignment = Some(node.into());
|
||||
self.visit_expr(&node.target);
|
||||
self.current_assignment = None;
|
||||
self.visit_expr(&node.value);
|
||||
}
|
||||
ast::Expr::Lambda(lambda) => {
|
||||
if let Some(parameters) = &lambda.parameters {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue