Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] local variable use in list comprehension not highlighted #55

Open
mtaran-google opened this issue Oct 10, 2017 · 2 comments
Open

Comments

@mtaran-google
Copy link
Contributor

[x for x in blah]

Note that in python 2 (which is the main target of this mode) list/set/dict comprehensions leak the index variable(s) to the enclosing scope, but generator expressions do not. In python 3, none of them leak the index variable(s).

@marijnh
Copy link
Member

marijnh commented Oct 10, 2017

In general, modes work front-to-back, so indeed, at the use of x, it won't have seen the declaration of x yet. I've added a kludge in attached patch to handle this specific case (the expression of a comprehension being a single variable), but I handling it generally for comprehensions where the initial expression is more complex isn't realistic with this approach. Is that acceptable?

@mtaran-google
Copy link
Contributor Author

Let's leave this open for now. When we start showing these modes to more users, I'll pass along any bug reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants