← Back to Pull requests

regex: clean up/refactor some EVAL code #24985

Open
iabyn opened this pull request with 766 lines diff across 7 files
View on GitHub
iabyn iabyn commented on Oct 20, 2026 18:05 UTC
Author

Several commits which collectively refactor and simplify the code which handles /(?{...})/ and similar, and moves the actual perl-calling part of it into a separate static function.

  • This set of changes does not require a perldelta entry.
  • Diff: 766 lines (+426 / -340) across 7 files Reviewer: tonycoz Review duration: 19983m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.52) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 766 lines diff across 7 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.81 · 5 substantive comment(s)
    0.81
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    86%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.397
    Real PR Conversation Timeline
    9 items
    tonycoz tonycoz commented on code on Oct 22, 2026 00:06 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;

    before could be declared at it's first use.

    Giving it type ptrdiff_t should avoid the need to cast it too, and it's not modified after that point so it could be const.

    gimme is only used by PUSH_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->); that I could see, it isn't modified, nor is a pointer taken, so it could be moved to point of use and made const.

    I'd be inclined to move ret down too, just after SPAGAIN.

    tonycoz tonycoz commented on code on Oct 22, 2026 00:34 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;
    +    OP * const oop = PL_op;
    +    COP * const ocurcop = PL_curcop;
    +    OP *nop;
    +    CV *newcv;
    +    SV *ret;
    +    U8 gimme = G_SCALAR;
    +    RXi_GET_DECL(rex, rexi);
    +
    +#ifdef DEBUGGING
    +    DECLARE_AND_GET_RE_DEBUG_FLAGS;
    +#endif
    +
    +    if (!reginfo->caller_cv)
    +        reginfo->caller_cv = find_runcv(NULL);
    +
    +    if (rexi->data->what[n] == 'r') { /* code from an external qr */
    +        newcv = (ReANY(
    +                        (REGEXP*)(rexi->data->data[n])
    +                ))->qr_anoncv;
    +        nop = (OP*)rexi->data->data[n+1];
    +    }
    +    else if (rexi->data->what[n] == 'l') { /* literal code */
    +        newcv = reginfo->caller_cv;
    +        nop = (OP*)rexi->data->data[n];
    +        assert(CvDEPTH(newcv));
    +    }
    +    else {
    +        /* literal with own CV */
    +        assert(rexi->data->what[n] == 'L');
    +        newcv = rex->qr_anoncv;
    +        nop = (OP*)rexi->data->data[n];
    +    }
    +
    +    /* Some notes about MULTICALL and the context and save stacks.
    +     *
    +     * In something like
    +     *   /...(?{ my $x)}...(?{ my $y)}...(?{ my $z)}.../
    +     * since codeblocks don't introduce a new scope (so that
    +     * local() etc accumulate), at the end of a successful
    +     * match there will be a SAVEt_CLEARSV on the savestack
    +     * for each of $x, $y, $z. If the three code blocks above
    +     * happen to have come from different CVs (e.g. via
    +     * embedded qr//s), then we must ensure that during any
    +     * savestack unwinding, PL_comppad always points to the
    +     * right pad at each moment. We achieve this by
    +     * interleaving SAVEt_COMPPAD's on the savestack whenever
    +     * there is a change of pad.
    +     * In theory whenever we call a code block, we should
    +     * push a CXt_SUB context, then pop it on return from
    +     * that code block. This causes a bit of an issue in that
    +     * normally popping a context also clears the savestack
    +     * back to cx->blk_oldsaveix, but here we specifically
    +     * don't want to clear the save stack on exit from the
    +     * code block.
    +     * Also for efficiency we don't want to keep pushing and
    +     * popping the single SUB context as we backtrack etc.
    +     * So instead, we push a single context the first time
    +     * we need, it, then hang onto it until the end of this
    +     * function. Whenever we encounter a new code block, we
    +     * update the CV etc if that's changed. During the times
    +     * in this function where we're not executing a code
    +     * block, having the SUB context still there is a bit
    +     * naughty - but we hope that no-one notices.
    +     * When the SUB context is initially pushed, we fake up
    +     * cx->blk_oldsaveix to be as if we'd pushed this context
    +     * on first entry to S_regmatch rather than at some random
    +     * point during the regexe execution. That way if we
    +     * croak, popping the context stack will ensure that
    +     * *everything* SAVEd by this function is undone and then
    +     * the context popped, rather than e.g., popping the
    +     * context (and restoring the original PL_comppad) then
    +     * popping more of the savestack and restoring a bad
    +     * PL_comppad.
    +     */
    +
    +    /* If this is the first EVAL, push a MULTICALL. On
    +     * subsequent calls, if we're executing a different CV, or
    +     * if PL_comppad has got messed up from backtracking
    +     * through SAVECOMPPADs, then refresh the context.
    +     */
    +    if (   newcv      != reginfo->last_pushed_cv
    +        || PL_comppad != reginfo->last_pad)
    +    {
    +        U8 flags = (CXp_SUB_RE |
    +                    ((newcv == reginfo->caller_cv)
    +                                ? CXp_SUB_RE_FAKE : 0));
    +        SAVECOMPPAD();
    +        if (reginfo->last_pushed_cv) {
    +            CHANGE_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
    +        }
    +        else {
    +            PUSH_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
    +        }
    +        /* see notes above */
    +        CX_CUR()->blk_oldsaveix = orig_savestack_ix;
    +
    +        reginfo->last_pushed_cv = newcv;
    +    }
    +    else {
    +        /* these assignments are just to silence compiler
    +         * warnings */
    +        reginfo->multicall_cop = NULL;
    +    }
    +    reginfo->last_pad = PL_comppad;
    +
    +    /* the initial nextstate you would normally execute
    +     * at the start of an eval (which would cause error
    +     * messages to come from the eval), may be optimised
    +     * away from the execution path in the regex code blocks;
    +     * so manually set PL_curcop to it initially */
    +    {
    +        OP *o = cUNOPx(nop)->op_first;
    +        assert(o->op_type == OP_NULL);
    +        if (o->op_targ == OP_SCOPE) {
    +            o = cUNOPo->op_first;
    +        }
    +        else {
    +            assert(o->op_targ == OP_LEAVE);
    +            o = cUNOPo->op_first;
    +            assert(o->op_type == OP_ENTER);
    +            o = OpSIBLING(o);
    +        }
    +
    +        if (o->op_type != OP_STUB) {
    +            assert(OP_TYPE_IS_COP_NN(o)
    +                    || (o->op_type == OP_NULL
    +                        &&  (  o->op_targ == OP_NEXTSTATE
    +                            || o->op_targ == OP_DBSTATE
    +                            )
    +                        )
    +            );
    +            PL_curcop = (COP*)o;
    +        }
    +    }
    +    nop = nop->op_next;
    +
    +    DEBUG_STATE_r( re_printf(
    +        "  re EVAL PL_op = 0x%" UVxf "\n", PTR2UV(nop)) );
    +
    +    /* we don't use MULTICALL here as we want to call the
    +     * first op of the block of interest, rather than the
    +     * first op of the sub. Also, we don't want to free
    +     * the savestack frame */
    +    before = (IV)(SP-PL_stack_base);
    +    PL_op = nop;
    +    CALLRUNOPS(aTHX);			/* Scalar context. */
    +    SPAGAIN;
    +    if ((IV)(SP-PL_stack_base) == before)
    +        ret = &PL_sv_undef;   /* protect against empty (?{}) blocks. */
    +    else {
    +        ret = POPs;
    +        PUTBACK;
    +    }
    +
    +    /* before restoring everything, evaluate the returned
    +     * value, so that 'uninit' warnings don't use the wrong
    +     * PL_op or pad. Also need to process any magic vars
    +     * (e.g. $1) *before* parentheses are restored */
    +
    +    PL_op = NULL;
    +
    +    if (logical == 0) {       /* /(?{ ... })/ and /(*{ ... })/ */
    +        SV *replsv = save_scalar(PL_replgv);
    +        sv_setsv(replsv, ret); /* $^R */
    +        SvSETMAGIC(replsv);
    +    }
    +    else if (logical == 1) { /*   /(?(?{...})X|Y)/    */
    +        if (!SvTRUE_NN(ret))
    +            ret = NULL;
    +    }
    +    else {                   /*  /(??{ ... })  */
    +        /*  if its overloaded, let the regex compiler handle

    should this assert(logical == 2)?

    Or should it be a switch?

    Also, something else to refactor would be the magic numbers, but that might be out of context.

    tonycoz tonycoz commented on code on Oct 22, 2026 00:43 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;
    +    OP * const oop = PL_op;
    +    COP * const ocurcop = PL_curcop;
    +    OP *nop;
    +    CV *newcv;
    +    SV *ret;
    +    U8 gimme = G_SCALAR;
    +    RXi_GET_DECL(rex, rexi);
    +
    +#ifdef DEBUGGING
    +    DECLARE_AND_GET_RE_DEBUG_FLAGS;
    +#endif
    +
    +    if (!reginfo->caller_cv)
    +        reginfo->caller_cv = find_runcv(NULL);
    +
    +    if (rexi->data->what[n] == 'r') { /* code from an external qr */

    Also a natural switch where the magic letters could use names (the switch might be a matter of taste, and the magic letters might be out of scope, so feel free to dismiss.)

    iabyn iabyn commented on code on Oct 27, 2026 10:37 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;

    All done now, in an extra commit entitled 'tweak S_run_code_block()'

    iabyn iabyn commented on code on Oct 27, 2026 10:38 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;
    +    OP * const oop = PL_op;
    +    COP * const ocurcop = PL_curcop;
    +    OP *nop;
    +    CV *newcv;
    +    SV *ret;
    +    U8 gimme = G_SCALAR;
    +    RXi_GET_DECL(rex, rexi);
    +
    +#ifdef DEBUGGING
    +    DECLARE_AND_GET_RE_DEBUG_FLAGS;
    +#endif
    +
    +    if (!reginfo->caller_cv)
    +        reginfo->caller_cv = find_runcv(NULL);
    +
    +    if (rexi->data->what[n] == 'r') { /* code from an external qr */
    +        newcv = (ReANY(
    +                        (REGEXP*)(rexi->data->data[n])
    +                ))->qr_anoncv;
    +        nop = (OP*)rexi->data->data[n+1];
    +    }
    +    else if (rexi->data->what[n] == 'l') { /* literal code */
    +        newcv = reginfo->caller_cv;
    +        nop = (OP*)rexi->data->data[n];
    +        assert(CvDEPTH(newcv));
    +    }
    +    else {
    +        /* literal with own CV */
    +        assert(rexi->data->what[n] == 'L');
    +        newcv = rex->qr_anoncv;
    +        nop = (OP*)rexi->data->data[n];
    +    }
    +
    +    /* Some notes about MULTICALL and the context and save stacks.
    +     *
    +     * In something like
    +     *   /...(?{ my $x)}...(?{ my $y)}...(?{ my $z)}.../
    +     * since codeblocks don't introduce a new scope (so that
    +     * local() etc accumulate), at the end of a successful
    +     * match there will be a SAVEt_CLEARSV on the savestack
    +     * for each of $x, $y, $z. If the three code blocks above
    +     * happen to have come from different CVs (e.g. via
    +     * embedded qr//s), then we must ensure that during any
    +     * savestack unwinding, PL_comppad always points to the
    +     * right pad at each moment. We achieve this by
    +     * interleaving SAVEt_COMPPAD's on the savestack whenever
    +     * there is a change of pad.
    +     * In theory whenever we call a code block, we should
    +     * push a CXt_SUB context, then pop it on return from
    +     * that code block. This causes a bit of an issue in that
    +     * normally popping a context also clears the savestack
    +     * back to cx->blk_oldsaveix, but here we specifically
    +     * don't want to clear the save stack on exit from the
    +     * code block.
    +     * Also for efficiency we don't want to keep pushing and
    +     * popping the single SUB context as we backtrack etc.
    +     * So instead, we push a single context the first time
    +     * we need, it, then hang onto it until the end of this
    +     * function. Whenever we encounter a new code block, we
    +     * update the CV etc if that's changed. During the times
    +     * in this function where we're not executing a code
    +     * block, having the SUB context still there is a bit
    +     * naughty - but we hope that no-one notices.
    +     * When the SUB context is initially pushed, we fake up
    +     * cx->blk_oldsaveix to be as if we'd pushed this context
    +     * on first entry to S_regmatch rather than at some random
    +     * point during the regexe execution. That way if we
    +     * croak, popping the context stack will ensure that
    +     * *everything* SAVEd by this function is undone and then
    +     * the context popped, rather than e.g., popping the
    +     * context (and restoring the original PL_comppad) then
    +     * popping more of the savestack and restoring a bad
    +     * PL_comppad.
    +     */
    +
    +    /* If this is the first EVAL, push a MULTICALL. On
    +     * subsequent calls, if we're executing a different CV, or
    +     * if PL_comppad has got messed up from backtracking
    +     * through SAVECOMPPADs, then refresh the context.
    +     */
    +    if (   newcv      != reginfo->last_pushed_cv
    +        || PL_comppad != reginfo->last_pad)
    +    {
    +        U8 flags = (CXp_SUB_RE |
    +                    ((newcv == reginfo->caller_cv)
    +                                ? CXp_SUB_RE_FAKE : 0));
    +        SAVECOMPPAD();
    +        if (reginfo->last_pushed_cv) {
    +            CHANGE_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
    +        }
    +        else {
    +            PUSH_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
    +        }
    +        /* see notes above */
    +        CX_CUR()->blk_oldsaveix = orig_savestack_ix;
    +
    +        reginfo->last_pushed_cv = newcv;
    +    }
    +    else {
    +        /* these assignments are just to silence compiler
    +         * warnings */
    +        reginfo->multicall_cop = NULL;
    +    }
    +    reginfo->last_pad = PL_comppad;
    +
    +    /* the initial nextstate you would normally execute
    +     * at the start of an eval (which would cause error
    +     * messages to come from the eval), may be optimised
    +     * away from the execution path in the regex code blocks;
    +     * so manually set PL_curcop to it initially */
    +    {
    +        OP *o = cUNOPx(nop)->op_first;
    +        assert(o->op_type == OP_NULL);
    +        if (o->op_targ == OP_SCOPE) {
    +            o = cUNOPo->op_first;
    +        }
    +        else {
    +            assert(o->op_targ == OP_LEAVE);
    +            o = cUNOPo->op_first;
    +            assert(o->op_type == OP_ENTER);
    +            o = OpSIBLING(o);
    +        }
    +
    +        if (o->op_type != OP_STUB) {
    +            assert(OP_TYPE_IS_COP_NN(o)
    +                    || (o->op_type == OP_NULL
    +                        &&  (  o->op_targ == OP_NEXTSTATE
    +                            || o->op_targ == OP_DBSTATE
    +                            )
    +                        )
    +            );
    +            PL_curcop = (COP*)o;
    +        }
    +    }
    +    nop = nop->op_next;
    +
    +    DEBUG_STATE_r( re_printf(
    +        "  re EVAL PL_op = 0x%" UVxf "\n", PTR2UV(nop)) );
    +
    +    /* we don't use MULTICALL here as we want to call the
    +     * first op of the block of interest, rather than the
    +     * first op of the sub. Also, we don't want to free
    +     * the savestack frame */
    +    before = (IV)(SP-PL_stack_base);
    +    PL_op = nop;
    +    CALLRUNOPS(aTHX);			/* Scalar context. */
    +    SPAGAIN;
    +    if ((IV)(SP-PL_stack_base) == before)
    +        ret = &PL_sv_undef;   /* protect against empty (?{}) blocks. */
    +    else {
    +        ret = POPs;
    +        PUTBACK;
    +    }
    +
    +    /* before restoring everything, evaluate the returned
    +     * value, so that 'uninit' warnings don't use the wrong
    +     * PL_op or pad. Also need to process any magic vars
    +     * (e.g. $1) *before* parentheses are restored */
    +
    +    PL_op = NULL;
    +
    +    if (logical == 0) {       /* /(?{ ... })/ and /(*{ ... })/ */
    +        SV *replsv = save_scalar(PL_replgv);
    +        sv_setsv(replsv, ret); /* $^R */
    +        SvSETMAGIC(replsv);
    +    }
    +    else if (logical == 1) { /*   /(?(?{...})X|Y)/    */
    +        if (!SvTRUE_NN(ret))
    +            ret = NULL;
    +    }
    +    else {                   /*  /(??{ ... })  */
    +        /*  if its overloaded, let the regex compiler handle

    I've added the assert, but declined the switch and magic numbers suggestions

    iabyn iabyn commented on code on Oct 27, 2026 10:39 UTC
    Code Review
    regexec.c:1
    @@ -6610,6 +6610,245 @@ S_backup_one_WB_but_over_Extend_FO(pTHX_ WB_enum * previous,
         return wb;
     }
     
    +
    +/* S_run_code_block(): helper function for S_regmatch().
    + *
    + * Execute the perl code within a (?{...}) code block or similar.
    + *
    + * Returns an SV which is the processed return value of the code block:
    + * that includes anything which must be done before restoring PL_op,
    + * parens etc, so that (??{  undef }) warns in the right place and
    + * (??{ $1 }) gets the right capture value.
    + *
    + * The return value may be either a string or a REGEXP object.
    + * For a condition (logical==1), the return value is NULL or non-NULL
    + * depending on whether the code block's return value was SvTRUE().
    + *
    + * Params:
    + *
    + * orig_savestack_ix is the stack index at the start of the match.
    + *
    + * logical is 0/1/2 indicating (?{...}),  (?(?{...})X|Y),  (??{ ... })
    + *
    + * n is the value of ARG1u(scan) and is used as an index into the
    + * regex internal data to get the data for this EVAL's code block.
    + */
    +
    +static REGEXP *
    +S_run_code_block(pTHX_ regexp *rex, regmatch_info *reginfo,
    +                    I32 orig_savestack_ix, int logical, U32 n)
    +
    +{
    +    /* execute the code in the {...} */
    +
    +    dSP;
    +    IV before;
    +    OP * const oop = PL_op;
    +    COP * const ocurcop = PL_curcop;
    +    OP *nop;
    +    CV *newcv;
    +    SV *ret;
    +    U8 gimme = G_SCALAR;
    +    RXi_GET_DECL(rex, rexi);
    +
    +#ifdef DEBUGGING
    +    DECLARE_AND_GET_RE_DEBUG_FLAGS;
    +#endif
    +
    +    if (!reginfo->caller_cv)
    +        reginfo->caller_cv = find_runcv(NULL);
    +
    +    if (rexi->data->what[n] == 'r') { /* code from an external qr */

    I've declined these suggestions for now.

    tonycoz tonycoz approved these changes on Oct 27, 2026 21:48 UTC
    Approved Reviewer

    Approved these changes.

    khwilliamson khwilliamson approved these changes on Oct 28, 2026 09:28 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    iabyn iabyn
    Labels
    risk: low confidence: 86.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 51.5% (MEDIUM) · Higher = larger blast radius
    51.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 86.2% · Lower = rushed or shallow review
    86.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.1% · Safe to merge
    7.1%
    Repository