fix: detect readline with variable filehandle after block#372
Draft
toddr-bot wants to merge 2 commits into
Draft
fix: detect readline with variable filehandle after block#372toddr-bot wants to merge 2 commits into
toddr-bot wants to merge 2 commits into
Conversation
Reproduces GitHub issue #221 where <$fh> after a block like map { $_ } is incorrectly tokenized as separate < and > operators instead of PPI::Token::QuoteLike::Readline. $TODO: tests fail until the tokenizer fix is applied. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The regex that disambiguates < as operator vs readline after a closing brace only matched bareword filehandles like <FILE>. Adding \$? to the pattern lets it also match variable filehandles like <$fh>. Fixes #221 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.
Summary
When a
<$fh>readline operator is preceded by a map/grep/sort block, PPI incorrectly tokenizes it as two separate<and>operators instead of a singlePPI::Token::QuoteLike::Readline. The root cause is that the regex inWhitespace.pmthat disambiguates<after a closing brace}only matched bareword filehandles (<FILE>) but not variable filehandles (<$fh>).Fixes #221
Changes
\$?to the readline detection regex inToken/Whitespace.pmso it matches both<FILE>and<$fh>patterns after a closing bracemap,grep, andsortblocks followed by<$fh>and<FILE>Test plan
52_readline_after_blockverifies correct tokenization of<$fh>after map/grep/sort blocks$foo->{bar} < 2still correctly tokenizes<as an operatorGenerated by Kōan /fix
Quality Report
Changes: 5 files changed, 76 insertions(+), 3 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline