Skip to content

[mypyc] Raise NameError on undefined names - #19395

Merged
JukkaL merged 2 commits into
python:masterfrom
p-sawicki:undefined-function
Jul 8, 2025
Merged

JukkaL merged 2 commits into
python:masterfrom
p-sawicki:undefined-function

Conversation

@p-sawicki

Copy link
Copy Markdown
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.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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
@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