Skip to content

fix(<ARGV>): treat as diamond operator iterating @ARGV#626

Merged
fglock merged 1 commit intomasterfrom
feature/argv-diamond-readline-20260429-173009
Apr 29, 2026
Merged

fix(<ARGV>): treat as diamond operator iterating @ARGV#626
fglock merged 1 commit intomasterfrom
feature/argv-diamond-readline-20260429-173009

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 29, 2026

Summary

Fixes ./jcpan -t Slurp which 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:

sub slurp {
    local( $/, @ARGV ) = ( wantarray ? $/ : undef, @_ );
    return <ARGV>;
}

which would emit readline() on unopened filehandle and return nothing.

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.

Test plan

  • ./jcpan -t Slurp now PASSes 6/6 (was 4/6)
  • make (full unit test suite) passes
  • Repro one-liner: local @ARGV = ('/tmp/file1.txt'); my @lines = <ARGV>; now reads the file

Generated with Devin

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>
@fglock fglock merged commit e892920 into master Apr 29, 2026
2 checks passed
@fglock fglock deleted the feature/argv-diamond-readline-20260429-173009 branch April 29, 2026 15:47
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