summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-03-05 12:45:09 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2023-03-06 10:41:20 +0000
commit7a993362d98aecd43ecb9827773e5bd30947a5a2 (patch)
treefde6eeb10d73b7aa611904ce23286bc143f39b24 /toke.c
parent75ea41ae51200ab26d84c418f08859a784a71b85 (diff)
downloadperl-7a993362d98aecd43ecb9827773e5bd30947a5a2.tar.gz
Have start_subparse() call class_prepare_method_parse() if CVf_IsMETHOD
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index 768630481a..0f30ddca70 100644
--- a/toke.c
+++ b/toke.c
@@ -12633,7 +12633,8 @@ If C<is_format> is non-zero, the input is to be considered a format sub
(a specialised sub used to implement perl's C<format> feature); else a
normal C<sub>.
-C<flags> are added to the flags for C<PL_compcv>.
+C<flags> are added to the flags for C<PL_compcv>. C<flags> may include the
+C<CVf_IsMETHOD> bit, which causes the new subroutine to be a method.
This returns the value of C<PL_savestack_ix> that was in effect upon entry to
the function;
@@ -12646,6 +12647,10 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
{
const I32 oldsavestack_ix = PL_savestack_ix;
CV* const outsidecv = PL_compcv;
+ bool is_method = flags & CVf_IsMETHOD;
+
+ if (is_method)
+ croak_kw_unless_class("method");
SAVEI32(PL_subline);
save_item(PL_subname);
@@ -12660,6 +12665,8 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
CvOUTSIDE_SEQ(PL_compcv) = PL_cop_seqmax;
if (outsidecv && CvPADLIST(outsidecv))
CvPADLIST(PL_compcv)->xpadl_outid = CvPADLIST(outsidecv)->xpadl_id;
+ if (is_method)
+ class_prepare_method_parse(PL_compcv);
return oldsavestack_ix;
}