Skip to content

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

Closed
@markshannon

Description

@markshannon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions