Skip to content

Commit

Permalink
WIP initial hack at fixing GH#22121 by storing PL_prevailing_version …
Browse files Browse the repository at this point in the history
…in the frozen hinthash stored by ck_entereval()
  • Loading branch information
leonerd committed Apr 25, 2024
1 parent 7a2df06 commit 384b3bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -12416,6 +12416,8 @@ Perl_ck_eval(pTHX_ OP *o)
PERL_ARGS_ASSERT_CK_EVAL;

PL_hints |= HINT_BLOCK_SCOPE;
if(PL_prevailing_version != 0)
PL_hints |= HINT_LOCALIZE_HH;
if (o->op_flags & OPf_KIDS) {
SVOP * const kid = cSVOPx(cUNOPo->op_first);
assert(kid);
Expand Down Expand Up @@ -12457,6 +12459,7 @@ Perl_ck_eval(pTHX_ OP *o)
&& !(o->op_private & OPpEVAL_COPHH) && GvHV(PL_hintgv)) {
/* Store a copy of %^H that pp_entereval can pick up. */
HV *hh = hv_copy_hints_hv(GvHV(PL_hintgv));
hv_stores(hh, "CORE/prevailing_version", newSVuv(PL_prevailing_version));
OP *hhop;
hhop = newSVOP(OP_HINTSEVAL, 0, MUTABLE_SV(hh));
/* append hhop to only child */
Expand Down
7 changes: 7 additions & 0 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4062,6 +4062,7 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh)
else {
PL_hints = saveop->op_private & OPpEVAL_COPHH
? oldcurcop->cop_hints : (U32)saveop->op_targ;
PL_prevailing_version = 0; /* we might change this below */

/* making 'use re eval' not be in scope when compiling the
* qr/mabye_has_runtime_code_block/ ensures that we don't get
Expand All @@ -4076,6 +4077,12 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh)
SvREFCNT_dec(GvHV(PL_hintgv));
GvHV(PL_hintgv) = hh;
FETCHFEATUREBITSHH(hh);
SV *versv;
/* hh is a new copy for us to use; we are permitted to delete keys */
if((versv = hv_deletes(hh, "CORE/prevailing_version", 0)) && SvOK(versv)) {
SAVEI16(PL_prevailing_version);
PL_prevailing_version = SvUV(versv);
}
}
}
SAVECOMPILEWARNINGS();
Expand Down

0 comments on commit 384b3bc

Please sign in to comment.