Conversation
Member
|
Found this failure case: |
Member
|
Simpler repro: |
| code = """ | ||
| x = 1 | ||
| def f(): | ||
| [lambda: x for x in [1]] |
Member
There was a problem hiding this comment.
Suggested change
| [lambda: x for x in [1]] | |
| [lambda: x for x in [2]] |
As discussed:
- Use a different value (the test ran correctly but used the wrong
1) - Should change it to execute the lambda so we ensure the value of
xinside the lambda is right
carljm
marked this pull request as draft
September 27, 2024 23:14
|
@carljm I think the tests are not testing the exact situation in my original example. They already pass in Python 3.13. The intervening list comprehension needs to be in the innermost scope like my original example, which still fails. |
|
oh, sorry ignore me, I was confused. apparently the tests passed because I ran it at module scope. they are also tested in function scope, so that is ok, I think |
|
but maybe you should also add a test to also test a local in f() to be sure. (I keep getting confused by the change of the function names between our examples) |
|
This PR is stale because it has been open for 30 days with no activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the case where a comprehension iteration variable is inlined into a function that otherwise does not have a variable by that name, but the name should be a free variable from an enclosing scope passed through to other enclosed scopes.