Skip to content

fix: /xx ignores spaces and tabs inside character classes#39

Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-xx-charclass-space
Draft

fix: /xx ignores spaces and tabs inside character classes#39
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-xx-charclass-space

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

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

What

Under /xx (Perl 5.26+), unescaped spaces and tabs inside [...] character classes are now correctly ignored during parsing.

Why

The parser was treating spaces and tabs as literal anyof_char nodes under /xx, producing parse trees that didn't match Perl's actual semantics. For example, (?xx:[a b c]) created three character nodes (a, , b, c) instead of two (a, b, c).

How

Added a check in the cc handler (Handlers.pm) before the literal character catch-all: when the /xx flag bit (0x200) is active, consume and skip space/tab runs via redo. Escaped spaces (\ ) are unaffected since they route through the backslash handler first.

Testing

  • 12 new tests in t/08regex_flags.t covering: space stripping, tab stripping, newline preservation, escaped space preservation, inline (?xx:) syntax, and /x vs /xx comparison
  • Round-trip validation passes for all /xx character class patterns
  • Full test suite passes (676+ tests)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 29 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Under /xx (Perl 5.26+), unescaped SPACE and TAB characters inside
bracketed character classes should be ignored. The parser was treating
them as literal anyof_char nodes, producing incorrect parse trees.

Added skip logic in the cc handler that checks for the xx flag bit
(0x200) and consumes spaces/tabs without creating nodes. Escaped
spaces (\ ) are correctly preserved since they go through the
backslash handler before reaching the literal catch-all.

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