mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[red-knot] Add definition for augmented assignment (#12892)
## Summary This PR adds definition for augmented assignment. This is similar to annotated assignment in terms of implementation. An augmented assignment should also record a use of the variable but that's a TODO for now. ## Test Plan Add test case to validate that a definition is added.
This commit is contained in:
parent
df09045176
commit
aefaddeae7
4 changed files with 96 additions and 3 deletions
|
@ -463,6 +463,25 @@ mod tests {
|
|||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn augmented_assignment() {
|
||||
let TestCase { db, file } = test_case("x += 1");
|
||||
let scope = global_scope(&db, file);
|
||||
let global_table = symbol_table(&db, scope);
|
||||
|
||||
assert_eq!(names(&global_table), vec!["x"]);
|
||||
|
||||
let use_def = use_def_map(&db, scope);
|
||||
let definition = use_def
|
||||
.first_public_definition(global_table.symbol_id_by_name("x").unwrap())
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
definition.node(&db),
|
||||
DefinitionKind::AugmentedAssignment(_)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn class_scope() {
|
||||
let TestCase { db, file } = test_case(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue