Diamond operator ignores tied *ARGV after import-time traversal

Abierto
#2,111 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, perl
Área
backend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Perl
Estrellas
67
Forks
8
Merge medio
5 h 12 min
PR fusionados (30 d)
131

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fglock/PerlOnJava

Todos los issues de fglock/PerlOnJava

Issues similares

Más issues de Perl

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.