[red-knot] Fallback to attributes on types.ModuleType if a symbol can't be found in locals or globals (#13904)

This commit is contained in:
Alex Waygood 2024-10-29 10:59:03 +00:00 committed by GitHub
parent 7dd0c7f4bd
commit d2c9f5e43c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 278 additions and 13 deletions

View file

@ -195,6 +195,10 @@ impl<'db> SemanticIndexBuilder<'db> {
self.current_symbol_table().mark_symbol_bound(id);
}
fn mark_symbol_declared(&mut self, id: ScopedSymbolId) {
self.current_symbol_table().mark_symbol_declared(id);
}
fn mark_symbol_used(&mut self, id: ScopedSymbolId) {
self.current_symbol_table().mark_symbol_used(id);
}
@ -226,6 +230,9 @@ impl<'db> SemanticIndexBuilder<'db> {
if category.is_binding() {
self.mark_symbol_bound(symbol);
}
if category.is_declaration() {
self.mark_symbol_declared(symbol);
}
let use_def = self.current_use_def_map_mut();
match category {
@ -359,6 +366,7 @@ impl<'db> SemanticIndexBuilder<'db> {
// note that the "bound" on the typevar is a totally different thing than whether
// or not a name is "bound" by a typevar declaration; the latter is always true.
self.mark_symbol_bound(symbol);
self.mark_symbol_declared(symbol);
if let Some(bounds) = bound {
self.visit_expr(bounds);
}