Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Oct 25, 2024
1 parent 117bf55 commit 3739088
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2329,8 +2329,6 @@ impl<'db> TypeInferenceBuilder<'db> {
.expect("Symbol table should create a symbol for every Name node")
.is_bound();

let mut ty = Type::Unbound;

// In function-like scopes, any local variable (symbol that is bound in this scope) can
// only have a definition in this scope, or error; it never references another scope.
// (At runtime, it would use the `LOAD_FAST` opcode.)
Expand Down Expand Up @@ -2361,8 +2359,10 @@ impl<'db> TypeInferenceBuilder<'db> {

// No nonlocal binding, check module globals. Avoid infinite recursion if `self.scope`
// already is module globals.
if !file_scope_id.is_global() {
ty = global_symbol_ty(self.db, self.file, name);
let ty = if file_scope_id.is_global() {
Type::Unbound
} else {
global_symbol_ty(self.db, self.file, name)
};

// Still possibly unbound? All modules are instances of `types.ModuleType`;
Expand Down Expand Up @@ -2391,11 +2391,13 @@ impl<'db> TypeInferenceBuilder<'db> {
);
builtin_ty = typing_extensions_symbol_ty(self.db, name);
}
ty = ty.replace_unbound_with(self.db, builtin_ty);
ty.replace_unbound_with(self.db, builtin_ty)
} else {
ty
}
} else {
Type::Unbound
}

ty
}

fn infer_name_expression(&mut self, name: &ast::ExprName) -> Type<'db> {
Expand Down

0 comments on commit 3739088

Please sign in to comment.