Skip to content

fix: branch_reset qr() crash + 86-test qr() suite#36

Draft
toddr-bot wants to merge 3 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-branch-reset-qr
Draft

fix: branch_reset qr() crash + 86-test qr() suite#36
toddr-bot wants to merge 3 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-branch-reset-qr

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

@toddr-bot toddr-bot commented Apr 7, 2026

What

Fixes qr() method crash when called on regexes containing (?|...) branch reset groups, and adds comprehensive functional test coverage for the qr() pipeline.

Why

Calling $parser->qr on any pattern with (?|...) died with "Can't locate object method 'on' via package 'Regexp::Parser::branch_reset'". This broke a primary consumer API for branch reset patterns.

How

The bug: Parser.pm:251 checked family eq 'group' to detect non-capturing groups and extract their flag modifiers. branch_reset also has family => 'group' but no on()/off() methods (it has no flags). Changed to type eq 'group' which only matches the non-capturing group construct that actually carries flags.

The tests: Added t/18qr_functional.t — 86 tests that verify the full pipeline (parse → tree → qr → match) across all major construct types: literals, anchors, quantifiers (including possessive), character classes, flags, caret flags, lookahead/behind, atomic groups, named captures, branch reset, backtracking verbs, \K, script runs, quotemeta, Unicode properties, POSIX classes, \R/\h/\v/\X, conditionals, and escape sequences. Previously qr() was only tested incidentally in ~5 files.

Testing

All 1241 tests pass (1155 existing + 86 new).

🤖 Generated with Claude Code


Quality Report

Changes: 4 files changed, 201 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

toddr-bot and others added 3 commits April 7, 2026 05:34
The qr() method in Parser.pm checked `family eq 'group'` to detect
non-capturing groups and extract their flags. Since branch_reset also
has family 'group' but no on()/off() methods, calling qr() on a regex
like (?|(a)|(b)) crashed with "Can't locate object method 'on'".

Fix: check `type eq 'group'` instead, which only matches the
non-capturing group construct that actually has flag accessors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comprehensive test that verifies the full pipeline: source pattern →
parse → tree → qr() → match. Covers literals, anchors, quantifiers,
possessive quantifiers, character classes, shorthand classes, flags,
caret flags, lookahead/lookbehind, atomic groups, named captures,
branch reset, backtracking verbs, \K, script runs, quotemeta,
Unicode properties, POSIX classes, \R/\h/\v/\X, conditionals,
named characters, and escape sequences.

Previously qr() was only tested incidentally in ~5 files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…erls

(*script_run:) requires Perl 5.30+ and \N{NAME} in runtime patterns
requires lexer-time resolution only available in 5.30+. Both tests now
skip gracefully on older Perl versions instead of failing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant