KEMBAR78
[mypyc] Raise NameError on undefined names by p-sawicki · Pull Request #19395 · python/mypy · GitHub
Skip to content

Conversation

p-sawicki
Copy link
Collaborator

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error when accessing undefined name in untyped function

2 participants