Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am opening this PR to keep a Boolean expression as one call argument and preserve its operand evaluation order. The code below currently decompiles incorrectly in Python 3.14:
The current output adds an argument and evaluates
first()twice:The value-chain recognizer leaves the initial COPY-retained operand on the stack after pushing the reconstructed expression. A later call then sees an extra argument, or consumes its callee/NULL prefix incorrectly. This change consumes the matching retained operand while preserving unrelated argument and callee entries, including an earlier argument with the same value.
The same reconstruction also handles multiple OR tails:
The current parser can emit
None(a and (b or bool), c or d or e)instead. Each non-final OR operand must prove the same COPY/TO_BOOL/true-jump-to-one-merge protocol and matching discard. Arbitrary branches or different merge targets still fail recognition. The retained operand must be consumed together with this reconstruction so that extending the chain does not corrupt the enclosing call's stack.Variations include a preceding OR chain, method calls within an operand, storing the expression in a local variable, and other arguments before or after the expression. Pure AND and OR chains continue through their existing paths.
The recognizer applies to Python 3.13+, matching the introduction of
TO_BOOLand its COPY-based value-preservation protocol. The Boolean source expressions themselves predate this bytecode layout.