Branch: refs/heads/yves/capture_bug
  Home:   https://github.com/Perl/perl5
  Commit: 3ee274e72cf07853170bc1a93545d712363b5cc8
      
https://github.com/Perl/perl5/commit/3ee274e72cf07853170bc1a93545d712363b5cc8
  Author: Yves Orton <[email protected]>
  Date:   2026-10-12 (Mon, 12 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: 1c800bc573c7462bbe6f085338beb91d6df35b88
      
https://github.com/Perl/perl5/commit/1c800bc573c7462bbe6f085338beb91d6df35b88
  Author: Yves Orton <[email protected]>
  Date:   2026-10-12 (Mon, 12 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: 933b9cf4f815f0bf8bcc71e87594a3b29758daf2
      
https://github.com/Perl/perl5/commit/933b9cf4f815f0bf8bcc71e87594a3b29758daf2
  Author: Yves Orton <[email protected]>
  Date:   2026-10-12 (Mon, 12 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


Compare: https://github.com/Perl/perl5/compare/3ee274e72cf0%5E...933b9cf4f815

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

Reply via email to