fix: accept /p (preserve) flag in (?p:...) inline syntax#51
Draft
toddr-bot wants to merge 1 commit into
Draft
Conversation
The /p flag (preserve match vars, Perl 5.10+) was rejected by the
parser because the (?p handler intercepted 'p' before it could reach
the flag processing loop. Fix: only dispatch to (?p handler when
followed by { (for deprecated (?p{...}) logical syntax); otherwise
let 'p' fall through to flag processing like g/c/o.
Matches Perl's behavior: (?p) is silently accepted, (?-p) warns.
The flag is a no-op (returns 0x0) and stripped from visual output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Accept the
/p(preserve) flag in inline(?p:...)and(?p)syntax, matching Perl's behavior.Why
The parser rejected
(?p:x)with "Sequence (?p...) not recognized" because the(?phandler interceptedpbefore the flag processing loop. Perl 5.10+ accepts/pas a valid inline modifier (it enables${^PREMATCH},${^MATCH},${^POSTMATCH}).How
(?handler dispatch to only route to(?pwhen followed by{(for deprecated(?p{...})logical syntax)FLAG_pregistration matchingg/c/opattern — returns 0x0 (no-op), stripped from visual output(?-p)warns,(?p)is silentregex()API (no crash on uninitializedRx)Testing
t/11errors.tandt/10roundtrip.t(?p:x),(?-p:x),(?pi:x),(?p),(?p{...}),(?P<name>...)all behave correctly🤖 Generated with Claude Code
Quality Report
Changes: 4 files changed, 25 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline