Skip to content

fix: octal and unknown escape ranges crash in character classes#43

Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-octal-range-crash
Draft

fix: octal and unknown escape ranges crash in character classes#43
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-octal-range-crash

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

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

What

Fix crash when parsing character class ranges containing octal escapes ([\101-\132]) or unknown escapes ([\q-z]).

Why

The \ handler used object() for octal and unknown escapes inside character classes. Since object() returns undef during the SIZE_ONLY (first) pass, the range detection code crashed with "Can't call method 'visual' on an undefined value" when these escapes appeared as either endpoint of a range.

This is a long-standing bug — any character class range involving \NNN octal notation has always crashed.

How

Use force_object(anyof_char => ...) when in character class context ($cc is true), matching the pattern already established by \x, \c, and all other escape handlers. Two return paths in the \ handler were affected: the octal path and the fallback/unknown-escape path.

Testing

  • 14 new tests in t/06cclass.t covering octal-to-octal, literal-to-octal, octal-to-literal, hex-to-octal ranges, and round-trip stability
  • Full test suite passes (690+ tests)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 49 insertions(+), 2 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

The \ handler used object() for octal escapes (\101) and unknown escapes
(\q) inside character classes. Since object() returns undef during the
SIZE_ONLY pass, the range detection code crashed calling methods on undef
when these escapes appeared in ranges like [\101-\132].

Fix: use force_object(anyof_char => ...) when in character class context,
matching the pattern already used by \x, \c, and other escape handlers.

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