Skip to content

Commit 9059509

Browse files
committed
Revert "Revert "[perl #89544] Non-eval closures don’t need CvOUTSIDE""
This reverts commit 386907f. Reinstates the behaviour of CV outside references from 5.38, fixing #22547 Breaks #19370
1 parent 7911101 commit 9059509

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

cv.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ See L<perlguts/Autoloading with XSUBs>.
147147
#endif
148148
#define CVf_DYNFILE 0x1000 /* The filename is malloced */
149149
#define CVf_AUTOLOAD 0x2000 /* SvPVX contains AUTOLOADed sub name */
150-
/* 0x4000 previously CVf_HASEVAL */
150+
#define CVf_HASEVAL 0x4000 /* contains string eval */
151151
#define CVf_NAMED 0x8000 /* Has a name HEK */
152152
#define CVf_LEXICAL 0x10000 /* Omit package from name */
153153
#define CVf_ANONCONST 0x20000 /* :const - create anonconst op */
@@ -232,6 +232,10 @@ See L<perlguts/Autoloading with XSUBs>.
232232
#define CvAUTOLOAD_on(cv) (CvFLAGS(cv) |= CVf_AUTOLOAD)
233233
#define CvAUTOLOAD_off(cv) (CvFLAGS(cv) &= ~CVf_AUTOLOAD)
234234

235+
#define CvHASEVAL(cv) (CvFLAGS(cv) & CVf_HASEVAL)
236+
#define CvHASEVAL_on(cv) (CvFLAGS(cv) |= CVf_HASEVAL)
237+
#define CvHASEVAL_off(cv) (CvFLAGS(cv) &= ~CVf_HASEVAL)
238+
235239
#define CvNAMED(cv) (CvFLAGS(cv) & CVf_NAMED)
236240
#define CvNAMED_on(cv) (CvFLAGS(cv) |= CVf_NAMED)
237241
#define CvNAMED_off(cv) (CvFLAGS(cv) &= ~CVf_NAMED)

dump.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@ const struct flag_to_name cv_flags_names[] = {
18991899
{CVf_CVGV_RC, "CVGV_RC,"},
19001900
{CVf_DYNFILE, "DYNFILE,"},
19011901
{CVf_AUTOLOAD, "AUTOLOAD,"},
1902+
{CVf_HASEVAL, "HASEVAL,"},
19021903
{CVf_SLABBED, "SLABBED,"},
19031904
{CVf_NAMED, "NAMED,"},
19041905
{CVf_LEXICAL, "LEXICAL,"},

ext/Devel-Peek/t/Peek.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ do_test('reference to named subroutine without prototype',
364364
RV = $ADDR
365365
SV = PVCV\\($ADDR\\) at $ADDR
366366
REFCNT = (3|4)
367-
FLAGS = \\((?:HASEVAL,)?(?:NAMED)?\\) # $] < 5.015 || !thr
368-
FLAGS = \\(DYNFILE(?:,HASEVAL)?(?:,NAMED)?\\) # $] >= 5.015 && thr
367+
FLAGS = \\((?:HASEVAL(?:,NAMED)?)?\\) # $] < 5.015 || !thr
368+
FLAGS = \\(DYNFILE(?:,HASEVAL(?:,NAMED)?)?\\) # $] >= 5.015 && thr
369369
COMP_STASH = $ADDR\\t"main"
370370
START = $ADDR ===> \\d+
371371
ROOT = $ADDR
@@ -375,8 +375,8 @@ do_test('reference to named subroutine without prototype',
375375
DEPTH = 1(?:
376376
MUTEXP = $ADDR
377377
OWNER = $ADDR)?
378-
FLAGS = 0x(?:[c84]00)?0 # $] < 5.015 || !thr
379-
FLAGS = 0x[cd1459]000 # $] >= 5.015 && thr
378+
FLAGS = 0x(?:[c4]00)?0 # $] < 5.015 || !thr
379+
FLAGS = 0x[cd145]000 # $] >= 5.015 && thr
380380
OUTSIDE_SEQ = \\d+
381381
PADLIST = $ADDR
382382
PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)

lib/B/Deparse.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,7 @@ my sub g {
21632163
sub f { }
21642164
}
21652165
####
2166+
# TODO only partially fixed
21662167
# lexical state subroutine with outer declaration and inner definition
21672168
# CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
21682169
();

pad.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type)
16841684
"Pad clone on cv=0x%" UVxf "\n", PTR2UV(cv)));
16851685
CvCLONE_on(cv);
16861686
}
1687+
CvHASEVAL_on(cv);
16871688
}
16881689
}
16891690

@@ -1975,7 +1976,8 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside, HV *cloned,
19751976
PL_compcv = cv;
19761977
if (newcv) SAVEFREESV(cv); /* in case of fatal warnings */
19771978

1978-
CvOUTSIDE(cv) = CvREFCNT_inc_simple(outside);
1979+
if (CvHASEVAL(cv))
1980+
CvOUTSIDE(cv) = CvREFCNT_inc_simple(outside);
19791981

19801982
SAVESPTR(PL_comppad_name);
19811983
PL_comppad_name = protopad_name;

t/op/closure.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ $r = \$x
687687
isnt($s[0], $s[1], "cloneable with //ee");
688688
}
689689

690-
# [perl #89544] aka [GH #11286]
690+
# [perl #89544]
691691
{
692692
sub trace::DESTROY {
693693
push @trace::trace, "destroyed";
@@ -711,7 +711,6 @@ $r = \$x
711711
};
712712

713713
my $inner = $outer2->();
714-
local $TODO = "we need outside links for debugger behaviour";
715714
is "@trace::trace", "destroyed",
716715
'closures only close over named variables, not entire subs';
717716
}

t/op/eval.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ our $x = 1;
379379
is(db6(), 4);
380380

381381
# [GH #19370]
382+
local $TODO = "outside not available when needed";
382383
my sub d6 {
383384
DB::db3();
384385
}

0 commit comments

Comments
 (0)