Add a binding kind for comprehension targets (#9967)

## Summary

I was surprised to learn that we treat `x` in `[_ for x in y]` as an
"assignment" binding kind, rather than a dedicated comprehension
variable.
This commit is contained in:
Charlie Marsh 2024-02-12 20:09:39 -05:00 committed by GitHub
parent cf77eeb913
commit 5bc0d9c324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 91 additions and 35 deletions

View file

@ -432,6 +432,12 @@ pub enum BindingKind<'a> {
/// ```
LoopVar,
/// A binding for a comprehension variable, like `x` in:
/// ```python
/// [x for x in range(10)]
/// ```
ComprehensionVar,
/// A binding for a with statement variable, like `x` in:
/// ```python
/// with open('foo.py') as x: