Fix recursion warning for ‘no warnings; goto &sub’

Commit 309aab3a made goto &foo make the lexical hints of the caller of
the sub containing the goto visible when foo is called.  CORE subs
need this to function properly when ‘goneto’.  But in that commit I
put the PL_curcop assignment before the recursion check, causing the
warning settings of the caller to be used, instead of those at the
goto.  This commit moves the PL_curcop further down in pp_goto.
This commit is contained in:
Father Chrysostomos 2011-09-17 00:27:14 -07:00
parent e8ed61c58c
commit 426a09cda0
2 changed files with 6 additions and 2 deletions

View File

@ -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))

View File

@ -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.