fix: octal and unknown escape ranges crash in character classes#43
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: octal and unknown escape ranges crash in character classes#43toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
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>
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
Fix crash when parsing character class ranges containing octal escapes (
[\101-\132]) or unknown escapes ([\q-z]).Why
The
\handler usedobject()for octal and unknown escapes inside character classes. Sinceobject()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
\NNNoctal notation has always crashed.How
Use
force_object(anyof_char => ...)when in character class context ($ccis 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
t/06cclass.tcovering octal-to-octal, literal-to-octal, octal-to-literal, hex-to-octal ranges, and round-trip stability🤖 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