Remove defunct OPs in Perl_scalar/Perl_scalarvoid #23890
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.
my $x = (1,2,3);produces the following OP tree in blead:This is functionally equivalent to
my $x = 3;:Construction of the first tree typically generates "Useless use of X in scalar context" warnings, but special cases such as the constants
0and1are excluded from these warnings.This commit modifies the functions responsible for assigning scalar or void context to OPs to remove:
OP_NULLnodes with no kids and a following sibling.OP_LISTnodes with only a single-scalar-pushing kid OP.This transforms the first OP tree above into the second.
Besides having a "cleaner-looking" optree that's easier to follow when debuggging Perl code or porting, there are other practical benefits:
Note: this PR replaces #23523. It was easier to implement in op.c than I'd
originally anticipated and, as mentioned above, doing so reduces the number of
times such defunct nodes have to be processed during compilation.