fix(<ARGV>): treat as diamond operator iterating @ARGV#626
Merged
Conversation
In Perl, <ARGV> behaves identically to the null filehandle <>: it iterates over files named in @argv (falling back to STDIN when @argv was initially empty), rather than reading from a single named ARGV filehandle. Previously the parser treated <ARGV> like <STDIN> or <FILE>, emitting a plain readline against the (closed) ARGV filehandle. That made code like Slurp's local( $/, @argv ) = ( wantarray ? $/ : undef, @_ ); return <ARGV>; fail with "readline() on unopened filehandle" and return nothing, breaking jcpan -t Slurp (2/6 subtests). Special-case <ARGV> in parseDiamondOperator so it produces the same OperatorNode("<>", ...) that <> does, routing through DiamondIO which already handles @argv iteration, STDIN fallback, and aliased *ARGV globs correctly. Verified with `./jcpan -t Slurp` (now PASSes 6/6) and `make`. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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
Fixes
./jcpan -t Slurpwhich was failing 2/6 subtests due to<ARGV>not behaving like the diamond operator.In Perl,
<ARGV>is identical to the null filehandle<>: it iterates over files named in@ARGV. Previously the parser treated<ARGV>like<STDIN>or<FILE>, emitting a plain readline against the (closed) ARGV filehandle. That broke code like Slurp's:which would emit
readline() on unopened filehandleand return nothing.Special-case
<ARGV>inparseDiamondOperatorso it produces the sameOperatorNode("<>", ...)that<>does, routing throughDiamondIOwhich already handles@ARGViteration, STDIN fallback, and aliased*ARGVglobs.Test plan
./jcpan -t Slurpnow PASSes 6/6 (was 4/6)make(full unit test suite) passeslocal @ARGV = ('/tmp/file1.txt'); my @lines = <ARGV>;now reads the fileGenerated with Devin