Skip to content

Commit 028325e

Browse files
committed
don't record lazy snapshots of nonlocal or global symbols
1 parent d130a65 commit 028325e

File tree

1 file changed

+3
-0
lines changed
  • crates/ty_python_semantic/src/semantic_index

1 file changed

+3
-0
lines changed

crates/ty_python_semantic/src/semantic_index/builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,12 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> {
358358

359359
for nested_place in self.place_tables[popped_scope_id].places() {
360360
// We don't record lazy snapshots of attributes or subscripts, because these are difficult to track as they modify.
361+
// For the same reason, symbols declared as nonlocal or global are not recorded.
361362
// Also, if the enclosing scope allows its members to be modified from elsewhere, the snapshot will not be recorded.
362363
if !nested_place.is_name()
363364
|| self.scopes[enclosing_scope_id].visibility().is_public()
365+
|| nested_place.is_marked_nonlocal()
366+
|| nested_place.is_marked_global()
364367
{
365368
continue;
366369
}

0 commit comments

Comments
 (0)