Skip to content

[mypyc] Raise NameError on undefined names #19395

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

Merged
merged 2 commits into from
Jul 8, 2025

Conversation

p-sawicki
Copy link
Contributor

Fixes mypyc/mypyc#879

Changed the type of exception that is raised on undefined names from RuntimeError to NameError.

Moved the runtime error that refers to unexpected execution of unreachable code to shortcircuit_expr to keep existing behavior and generate the exception in blocks that are unreachable due to short-circuiting.

In the future this could probably be optimized to not generate any code at all and just constant-fold the boolean expression.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good.

@JukkaL JukkaL merged commit d503edf into python:master Jul 8, 2025
13 checks passed
@p-sawicki p-sawicki deleted the undefined-function branch July 8, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants