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 --- perly.y | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'perly.y') diff --git a/perly.y b/perly.y index ae5c22993f..c0c09092c5 100644 --- a/perly.y +++ b/perly.y @@ -94,7 +94,7 @@ %token PHASER %type grammar remember mremember -%type startsub startanonsub startformsub +%type startsub startanonsub startanonmethod startformsub %type mintro @@ -773,6 +773,11 @@ startanonsub: %empty /* start an anonymous subroutine scope */ SAVEFREESV(PL_compcv); } ; +startanonmethod: %empty /* start an anonymous method scope */ + { $$ = start_subparse(FALSE, CVf_ANON|CVf_IsMETHOD); + SAVEFREESV(PL_compcv); } + ; + startformsub: %empty /* start a format subroutine scope */ { $$ = start_subparse(TRUE, 0); SAVEFREESV(PL_compcv); } @@ -1333,17 +1338,10 @@ anonymous | KW_SUB_anon_sig startanonsub subattrlist sigsubbody %prec PERLY_PAREN_OPEN { SvREFCNT_inc_simple_void(PL_compcv); $$ = newANONATTRSUB($startanonsub, NULL, $subattrlist, $sigsubbody); } - | KW_METHOD_anon startanonsub + | KW_METHOD_anon startanonmethod subattrlist sigsubbody %prec PERLY_PAREN_OPEN { - croak_kw_unless_class("method"); - class_prepare_method_parse(PL_compcv); - } - subattrlist sigsubbody %prec PERLY_PAREN_OPEN - { - OP *body = $sigsubbody; - SvREFCNT_inc_simple_void(PL_compcv); - $$ = newANONATTRSUB($startanonsub, NULL, $subattrlist, body); + $$ = newANONATTRSUB($startanonmethod, NULL, $subattrlist, $sigsubbody); } ; -- cgit v1.2.1