Skip to content

Preserve separate evaluations in assignment grouping - #3

Open
EiNSTeiN- wants to merge 4 commits into
ejfkdev:mainfrom
EiNSTeiN-:fix/assignment-evaluation-identity
Open

EiNSTeiN- wants to merge 4 commits into
ejfkdev:mainfrom
EiNSTeiN-:fix/assignment-evaluation-identity

Conversation

@EiNSTeiN-

@EiNSTeiN- EiNSTeiN- commented Oct 13, 2026 •

Copy link
Copy Markdown

I am opening this PR to fix independent evaluations being collapsed into a chained assignment in pycdc. The two read() calls below must remain separate after decompilation:

def separate(read):
    left, right = read(), read()
    return left, right


def shared(read):
    left = right = read()
    return left, right

The parser recognizes both forms, but groups pending assignment stores using structural AST equality. The two independent read() ASTs in separate look identical, so they can become left = right = read(). That changes the call count, object identity, returned values and which call can raise. shared must retain one evaluation. The change in flush_pending_stores uses Rc::ptr_eq, which identifies a single evaluated expression propagated by COPY/DUP, rather than comparing the expression's spelling.

Controls include left, right = None, None and right = left = None.

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.

1 participant