-
Notifications
You must be signed in to change notification settings - Fork 559
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
S_newONCEOP: Rejig the op_next padop (Closes #18630) #22764
Open
richardleach
wants to merge
2
commits into
Perl:blead
Choose a base branch
from
richardleach:hydahy/18630_state
base: blead
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−17
Conversation
This file contains 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
tonycoz
reviewed
Nov 20, 2024
An array in scalar context is normally the number of elements in the array, but that doesn't appear to be the case for the trailing
|
Thanks, I'll look into it. I see that in:
Though not in:
|
Looks like it comes down to clobbering (or not) |
richardleach
force-pushed
the
hydahy/18630_state
branch
2 times, most recently
from
November 21, 2024 10:06
d88bcce
to
5835483
Compare
Should a _state_ array or hash be declared immediately prior to returning, the error "Bizarre copy of HASH in subroutine exit" error would be triggered. Now, the array or hash is returned without error. Specifically: * Instead of always creating a PADSV, the appropriate padop is created. * The OPf_REF flag is switched off, allowing the return of the container variable's contents rather than the container SV itself. * The OPf_MOD & OPf_SPECIAL flags are switches off, as they are not relevant to this version of the padop. Note: The op created has been renamed from "other" to "nextop", since it is linked to the ONCE op via op_next, not op_other. Fixes GH#18630
Prior to this commit, padops associated with OP_ONCE might serve no purpose in a void context. Since the context is not known at the point of the OP_ONCE creation, the padops have retained the STATE flag, but not the LVINTRO flag. This prevented Perl_scalarvoid from warning "Useless use of private variable in void context". In this commit, the STATE flag is removed and Perl_scalarvoid modified such that when a OP_ONCE padop is found in void context, the op_next pointer on the OP_ONCE is silently modified to skip over the padop.
richardleach
force-pushed
the
hydahy/18630_state
branch
from
November 21, 2024 10:11
5835483
to
52a4c77
Compare
Ok, I think it has the correct behaviour now. |
tonycoz
approved these changes
Nov 25, 2024
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.
Two related changes pertaining to the padop executed when an OP_ONCE is encountered for the nth time.
S_newONCEOP: correctly copy array/hash at subroutine exit
Should a state array or hash be declared immediately prior to
returning, the error
Bizarre copy of HASH in subroutine exit
errorwould be triggered. Now, the array or hash is returned without error.
Closes Returning state hash-assign risks "Bizarre copy of HASH in subroutine exit" #18630
S_newONCEOP/Perl_scalarvoid: skip over padops uselss in void context
Rejigs how the nth-time padop is handled in void context to avoid the
warning "Useless use of private variable in void context". The OPf_STATE
flag is removed and the op_next chain now explicitly skips the padop.