Diamond operator ignores tied *ARGV after import-time traversal

Aberta
#2,111 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
52/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java, perl
Domínio
backend, testing

Direção de pesquisa

Start with OpcodeHandlerExtended.executeReadline, DiamondIO.readline and openNextFile, and TieHandle.tiedReadline to trace how reads are dispatched after *ARGV is tied. Reproduce the failures with the upstream t/01_argv.t commands in the issue, then compare tied-handle reads with ordinary @ARGV iteration and EOF behavior. Done when both backends honor the tied handle’s READLINE after import-time traversal and regression coverage passes.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area:io bug

Summary

<> stops using *ARGV after ARGV::JSON consumes the command-line file during module import and then ties *ARGV. PerlOnJava returns undef for reads that should invoke the tied handle's READLINE method.

This was reported by CPAN random run 20261118-104825-43075 for ARGV-JSON-0.01, target ARGV::JSON. The failure is in t/01_argv.t (tests 2 and 3, lines 32 and 37); t/00_compile.t passes.

Reproduction and results

The upstream test sets @ARGV to t/data/01.json, then loads ARGV::JSON. Its import method reads the file using <> and ties *ARGV. The test then expects scalar and list-context <> reads to return the decoded JSON values.

From the extracted ARGV-JSON-0.01 distribution directory:

PERL5LIB=blib/lib jperl t/01_argv.t
PERL5LIB=blib/lib jperl --interpreter t/01_argv.t

Both PerlOnJava backends reproduce the two failures. For the first read, the actual value is undef; the expected value is the first decoded hash. The list read is empty instead of returning the remaining array and hash values. The final EOF assertion passes.

The archived system-Perl oracle ran the same distribution and passed all 5 tests (t/00_compile.t and t/01_argv.t) under Perl 5.42.2. The archived PerlOnJava run failed 2 of 5 tests. A local follow-up reproduced the result on both backends; its executable reports build 543f9dfef, on Temurin Java 24.0.2 / macOS 15.6 ARM64.

Root cause

The import-time <> loop starts DiamondIO traversal while @ARGV contains the fixture filename. It consumes that filename and reaches EOF before ARGV::JSON ties *ARGV. The later <> operations are still routed by OpcodeHandlerExtended.executeReadline to DiamondIO.readline. That code continues the existing diamond traversal; when it needs another input, openNextFile shifts from the now-empty @ARGV and reports EOF. It does not dispatch those reads to the newly tied ARGV handle's READLINE method.

Relevant code paths are OpcodeHandlerExtended.executeReadline, DiamondIO.readline / openNextFile, and TieHandle.tiedReadline. The behavior to fix is the interaction between the diamond operator's traversal state and a tied *ARGV: reads after tying must honor the handle's READLINE, while ordinary @ARGV file iteration and EOF behavior remain intact.

Related coverage

The repository has adjacent diamond-state and tied-handle coverage, including the changes in PR #1463, but that coverage does not exercise tying *ARGV after an import-time diamond traversal has consumed its input. The upstream ARGV-JSON-0.01 test is a focused reproducer suitable for project regression coverage.

No XS or native dependency is involved. Searches of existing issues for ARGV::JSON, tied ARGV, and DiamondIO found no issue covering this behavior.

Linguagem predominante
Perl
Estrelas
67
Forks
8
Merge médio
5h 12min
PRs com merge (30d)
131

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de fglock/PerlOnJava

Todas as issues de fglock/PerlOnJava

Issues semelhantes

Mais issues de Perl

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.