Skip to content

Commit

Permalink
Fixes minor bug in SemanticModel::lookup_symbol (#14643)
Browse files Browse the repository at this point in the history
## Summary

This came up as part of #12927 when implementing
`SemanticModel::simulate_runtime_load`.

Should be fairly self-explanatory, if the scope returns a binding with
`BindingKind::Annotation` the bottom part of the loop gets skipped, so
there's no chance for `seen_function` to have been updated. So unless
there's something subtle going on here, like function scopes never
containing bindings with `BindingKind::Annotation`, this seems like a
bug.

## Test Plan

`cargo nextest run`
  • Loading branch information
Daverball authored Nov 27, 2024
1 parent 8a7ba5d commit 6d61c8a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions crates/ruff_python_semantic/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ impl<'a> SemanticModel<'a> {
}

class_variables_visible = scope.kind.is_type() && index == 0;
seen_function |= scope.kind.is_function();

if let Some(binding_id) = scope.get(symbol) {
match self.bindings[binding_id].kind {
Expand All @@ -661,9 +662,6 @@ impl<'a> SemanticModel<'a> {
return None;
}
}

// FIXME: Shouldn't this happen above where `class_variables_visible` is set?
seen_function |= scope.kind.is_function();
}

None
Expand Down

0 comments on commit 6d61c8a

Please sign in to comment.