diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2023-03-05 12:45:09 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2023-03-06 10:41:20 +0000 |
commit | 7a993362d98aecd43ecb9827773e5bd30947a5a2 (patch) | |
tree | fde6eeb10d73b7aa611904ce23286bc143f39b24 /perly.y | |
parent | 75ea41ae51200ab26d84c418f08859a784a71b85 (diff) | |
download | perl-7a993362d98aecd43ecb9827773e5bd30947a5a2.tar.gz |
Have start_subparse() call class_prepare_method_parse() if CVf_IsMETHOD
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -94,7 +94,7 @@ %token <ival> PHASER %type <ival> grammar remember mremember -%type <ival> startsub startanonsub startformsub +%type <ival> startsub startanonsub startanonmethod startformsub %type <ival> 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); } ; |