From 7a993362d98aecd43ecb9827773e5bd30947a5a2 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sun, 5 Mar 2023 12:45:09 +0000 Subject: Have start_subparse() call class_prepare_method_parse() if CVf_IsMETHOD --- toke.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'toke.c') 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 non-zero, the input is to be considered a format sub (a specialised sub used to implement perl's C feature); else a normal C. -C are added to the flags for C. +C are added to the flags for C. C may include the +C bit, which causes the new subroutine to be a method. This returns the value of C 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; } -- cgit v1.2.1