Branch: refs/heads/yves/capture_bug
  Home:   https://github.com/Perl/perl5
  Commit: e785e128f526ba9745a6319057d458660ec87339
      
https://github.com/Perl/perl5/commit/e785e128f526ba9745a6319057d458660ec87339
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M pod/perldelta.pod
    M regcomp_study.c
    M t/re/re_tests

  Log Message:
  -----------
  regcomp.c: preserve captures when nested repeat iterations fail

We leave repeats containing captures inside nested quantifiers as
CURLYX. CURLYM can reconstruct a capture around its whole body, but
cannot restore captures inside a nested quantifier when an iteration
fails or is backtracked. CURLYX already has the iteration checkpoints
needed to restore these captures.

For example, "aa" =~ /(?:(aa){2})*/ matches the empty string and now
leaves $1 undefined. Likewise, "aabbaa" =~ /(?:([ab]{2}){2})*/ matches
"aabb" and preserves "bb" from the completed iteration, rather than
"aa" from the failed next iteration.

Fixes:
    https://github.com/Perl/perl5/issues/24945


  Commit: 7d42e8caaa543223740dcc41353ecd98ebffc26e
      
https://github.com/Perl/perl5/commit/7d42e8caaa543223740dcc41353ecd98ebffc26e
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M pod/perldelta.pod
    M pod/perlre.pod
    M regexec.c
    M regexp.h
    M t/re/re_tests

  Log Message:
  -----------
  regexec.c: restore captures after negative assertions

We save the incoming capture state before evaluating a negative
assertion and restore it after each attempt. A successful negative
assertion means its body failed. Captures made along that failed path
should be rolled back, just as they are when an alternation branch
fails.

For example, "a" =~ /\A(?!(a)b)a\z/ now leaves $1 undefined. A later
backreference or condition can no longer use the stale capture. We
also restore the incoming state before retrying a variable-length
negative lookbehind at another starting position.

Captures remain available to backreferences and embedded code while
the assertion body is being evaluated. Positive assertions and atomic
groups continue to retain captures from successful bodies. Assertions
in patterns without captures do not need a capture checkpoint.

Fixes:
    https://github.com/Perl/perl5/issues/24946
    https://github.com/Perl/perl5/issues/14387


  Commit: d1320ef07a1f0f45b5f90d2031f5bd7843ca91f4
      
https://github.com/Perl/perl5/commit/d1320ef07a1f0f45b5f90d2031f5bd7843ca91f4
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M pod/perldelta.pod
    M regexec.c
    M t/re/pat.t
    M t/re/pat_rt_report.t
    M t/re/re_tests

  Log Message:
  -----------
  regexec.c: clear captures when CURLYX chooses zero repetitions

We clear the captures in a CURLYX body when choosing zero repetitions,
as CURLYN and CURLYM do. We save the incoming values first so that
backtracking into the body can use the original capture state.

Adding a no-op (?{}) no longer changes whether

    "abba" =~ /\A(?:(a)?b)+\1\z/

matches. Both forms reject the string because the final iteration
skips (a), leaving no capture for \1. A capture which participates and
matches the empty string remains defined.

Fixes:
    https://github.com/Perl/perl5/issues/18865
    https://github.com/Perl/perl5/issues/8267


  Commit: 2ce2b0dcac9730fe02cc75bf6c21c4a311839334
      
https://github.com/Perl/perl5/commit/2ce2b0dcac9730fe02cc75bf6c21c4a311839334
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M regcomp.c
    M regcomp.h
    M regcomp_debug.c
    M regcomp_study.c
    M regexec.c

  Log Message:
  -----------
  regex: name the repeat bounds and capture range of CURLY nodes

Add CURLY_MIN_REPEAT(), CURLY_MAX_REPEAT(), CURLY_FIRST_CAPTURE() and
CURLY_LAST_CAPTURE(), with matching setters. Convert the numeric macros we use
right now into something with semantic value.

Add and use CURLY_HAS_CAPTURES() when code needs to test whether a CURLY node
has a capture range at all. CURLY_FIRST_CAPTURE() is always true if
CURLY_LAST_CAPTURE() is true[1], so we can just fetch the full word and use a
semantically better named macros while we do.

In a follow up commit we should create similar macros and add op-type asserts
to all of them at once. For now these are fairly obvious transformations.

[1] the first bound is npar_before + 1, and the last bound is always >= the
    first bound. The last bound is only set in the same branch, so it cannot
    be nonzero unless the first is. Testing the packed field is therefore
    equivalent to testing the first bound.


Compare: https://github.com/Perl/perl5/compare/0a617e573f05...2ce2b0dcac97

To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to