Skip to content

Process $self in method subs as a subsignature parameter #23565

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

Open
wants to merge 3 commits into
base: blead
Choose a base branch
from

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Aug 12, 2025

This has at least three advantages:

  • Removes more special-case code from class.c and makes generated optrees more similar to others

  • Ensures that no other ops appear in the optree before signature handling (as the OP_METHSTART used to). This will be useful for upcoming faster-signatures changes

  • Corrects the previous "off-by-one" error in parameter counts as reported by the argument count check exception messages

Includes addition to perldelta

This flag indicates that `$self` argument handling has already been
performed by the subroutine signature, so it should find the value
already in the pad.
A "fence op" is a miscellaneous op fragment that performs some work for
side-effects during processing of a subroutine signature. In terms of
timing, it will run at some time after any previously-defined arguments
have been assigned from argument values passed in by the caller, but
before any defaulting expressions for parameters that come after it are
run.

We specifically make no guarantees about whether parameters defined
after this op have had their values assigned, nor whether defaulting
expressions of earlier parameters have already been invoked. This is
intentional because upcoming changes will change the order of these.

The intention here is that method subroutines will use a fence op for
the `OP_METHSTART` behaviour, ensuring that subsequent defaulting
expressions can see the values of field bindings established by
processing the `$self` parameter.
This has at least three advantages:

 * Removes more special-case code from `class.c` and makes generated
   optrees more similar to others

 * Ensures that no other ops appear in the optree before signature
   handling (as the OP_METHSTART used to). This will be useful for
   upcoming faster-signatures changes

 * Corrects the previous "off-by-one" error in parameter counts as
   reported by the argument count check exception messages
@leonerd leonerd force-pushed the self-as-subsignature branch from 1325801 to 600a61c Compare August 12, 2025 15:06
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