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

[mypyc] Fix regression with nested functions #16484

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #16480

Fix is straightforward, but also suspicious, since I am not sure how it ever worked without this.

@mr-c
Copy link
Contributor

mr-c commented Nov 14, 2023

I can confirm that this fixes my original issue, thank you!

@ilevkivskyi
Copy link
Member Author

Some more info for reviewers (@JukkaL @msullivan @ichard26): currently visit_symbol_node() is only called from visit_name_expr(), but the former method has two branches: for when we already seen the name, and when we see it first time. These branches are hit when a NameExpr appears as a reference, or as an assignment l.h.s. (i.e. definition), correspondingly. This is why free_variables are set correctly for variables, but for functions this was broken, because visit_symbol_node() was not called on function definition, only when it appears as reference.

Copy link
Collaborator

@ichard26 ichard26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't merge, but LGTM. I appreciate the explanation, it was helpful to understand the patch!

@ilevkivskyi ilevkivskyi merged commit b425bd6 into python:master Nov 16, 2023
13 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-mypyc-regr branch November 16, 2023 11:56
@mr-c mr-c mentioned this pull request Nov 16, 2023
2 tasks
@AlexWaygood AlexWaygood mentioned this pull request Nov 18, 2023
3 tasks
JukkaL pushed a commit that referenced this pull request Nov 22, 2023
Fixes #16480

Fix is straightforward, but also suspicious, since I am not sure how it
ever worked without this.
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

Successfully merging this pull request may close these issues.

1.7.0 regression with mypyc
4 participants