diff --git a/pp_ctl.c b/pp_ctl.c index 603d0a5782..2e89b7053c 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2908,7 +2908,6 @@ PP(pp_goto) } cx->blk_sub.cv = cv; cx->blk_sub.olddepth = CvDEPTH(cv); - PL_curcop = cx->blk_oldcop; CvDEPTH(cv)++; if (CvDEPTH(cv) < 2) @@ -2918,6 +2917,7 @@ PP(pp_goto) sub_crush_depth(cv); pad_push(padlist, CvDEPTH(cv)); } + PL_curcop = cx->blk_oldcop; SAVECOMPPAD(); PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv)); if (CxHASARGS(cx)) diff --git a/t/op/goto.t b/t/op/goto.t index 5fa3116e0b..f2f91629ec 100644 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -10,7 +10,7 @@ BEGIN { use warnings; use strict; -plan tests => 77; +plan tests => 78; our $TODO; my $deprecated = 0; @@ -415,7 +415,11 @@ sub recurse2 { my $x = shift; $_[0] ? +1 + recurse1($_[0] - 1) : 0 } +my $w = 0; +$SIG{__WARN__} = sub { ++$w }; is(recurse1(500), 500, 'recursive goto &foo'); +is $w, 0, 'no recursion warnings for "no warnings; goto &sub"'; +delete $SIG{__WARN__}; # [perl #32039] Chained goto &sub drops data too early.