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

Code generator is overly restrictive about writing to input variables. #131513

Closed
markshannon opened this issue Mar 20, 2025 · 0 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@markshannon
Copy link
Member

markshannon commented Mar 20, 2025

Bug report

Bug description:

In https://github.com/python/cpython/pull/130708/files#r2005817604
we want to replace an input variable, writing v = PyStackRef_MakeHeapSafe(v); but the code generator rejects this as unsafe: "writing to an input variable".
This mostly a good restriction as we don't want to accidentally lose a reference, but we should allow the replacement when it is safe.

This should be allowed:

tmp = PyStackRef_MakeHeapSafe(v);
DEAD(v);
v = tmp;

As we only write to a dead variable, which is safe.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant