mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
[red-knot] fix eager nested scopes handling (#16916)
## Summary From #16861, and the continuation of #16915. This PR fixes the incorrect behavior of `TypeInferenceBuilder::infer_name_load` in eager nested scopes. And this PR closes #16341. ## Test Plan New test cases are added in `annotations/deferred.md`.
This commit is contained in:
parent
64171744dc
commit
aca6254e82
9 changed files with 242 additions and 64 deletions
|
@ -256,11 +256,11 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
}
|
||||
|
||||
for nested_symbol in self.symbol_tables[popped_scope_id].symbols() {
|
||||
// Skip this symbol if this enclosing scope doesn't contain any bindings for
|
||||
// it, or if the nested scope _does_.
|
||||
if nested_symbol.is_bound() {
|
||||
continue;
|
||||
}
|
||||
// Skip this symbol if this enclosing scope doesn't contain any bindings for it.
|
||||
// Note that even if this symbol is bound in the popped scope,
|
||||
// it may refer to the enclosing scope bindings
|
||||
// so we also need to snapshot the bindings of the enclosing scope.
|
||||
|
||||
let Some(enclosing_symbol_id) =
|
||||
enclosing_symbol_table.symbol_id_by_name(nested_symbol.name())
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue