Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Preserve state variables across file-reading loops

未关闭
#1,475 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java, perl
领域
compilers

调研方向

Start with t/03-Nulls.t and t/04-Fix-Overlay.t, then trace the state-variable handling for source-file reads in both the JVM and interpreter backends. Preserve the filehandle loop, $. == 1 branch, and object assignment in a regression test. Done means both focused tests pass on both backends and the complete suite remains successful.

由索引模型根据 Issue 内容生成。

描述

area:backend area:cpan-port area:runtime bug

Summary

DataExtract::FixedWidth 0.09 fails two upstream tests under PerlOnJava because a state variable declared inside a file-reading loop does not retain the constructed object between iterations. The first iteration should initialize $fw; on the next iteration $fw is undefined and the test dies calling parse.

Reproduction

This was found in CPAN random run 20260921-124328-13959 at PerlOnJava commit d8e4fd417.

The affected upstream tests are:

  • t/03-Nulls.t
  • t/04-Fix-Overlay.t

Both tests have the same relevant structure:

while (my $line = <$fh>) {
    state $fw;

    if ($. == 1) {
        $fw = DataExtract::FixedWidth->new({
            header_row   => $line,
            null_as_undef => 1, # or fix_overlay => 1
        });
    }
    else {
        my $arr_ref = $fw->parse($line);
    }
}

Under PerlOnJava, the constructor branch runs for the first line, but $fw is undefined on the second line. The test then dies with:

Can't call method "parse" on an undefined value

The failure reproduces when running the actual test files with both the JVM backend and the interpreter backend. It is not a timeout or a dependency-installation failure.

Expected behavior

state $fw should retain its value for subsequent loop iterations, as it does under standard Perl. The first line should construct a DataExtract::FixedWidth object and later lines should call parse on that same object.

Results

Standard Perl passes the focused tests:

t/03-Nulls.t ........ ok
t/04-Fix-Overlay.t .. ok
All tests successful.
Files=2, Tests=15

The archived standard-Perl oracle also passes the complete distribution suite: 18 test files, 82 tests.

PerlOnJava fails:

t/03-Nulls.t       exited 255; planned 12 tests, ran 0
t/04-Fix-Overlay.t exited 255; planned 3 tests, ran 0
Files=18, Tests=68
Failed 2/18 test programs

The remaining 16 test programs pass. The test files are reproducible on both PerlOnJava execution backends.

Suspected area

The immediate failure surface is lowering or runtime handling of file-scoped state variables in this loop context. The interaction with Perl's $. input-line counter is also worth checking: the initialization branch is selected using $. == 1, and PerlOnJava may be handling the line counter or its association with the newly opened filehandle differently in the failing source-file context.

A simple scalar state loop can appear to work in a minimal -e invocation, so the regression test should preserve the source-file form, filehandle read loop, $. == 1 branch, and object assignment shown above.

Environment and scope

  • Distribution: DataExtract::FixedWidth 0.09
  • PerlOnJava backends: JVM and interpreter
  • Standard Perl oracle: Perl 5.42.2 on macOS
  • Native/XS code: none
  • Reverse-dependency analysis: not applicable; this is a pure-Perl distribution

This is an upstream compatibility failure, not a failure caused by missing services, display requirements, native libraries, or unsupported XS code.

主要语言
Perl
星标
64
派生
6
平均合并
5 小时 38 分钟
30 天内合并 PR
170

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fglock/PerlOnJava 的其他 Issue

查看 fglock/PerlOnJava 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。