Preserve state variables across file-reading loops
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.tt/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::FixedWidth0.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.
- Ngôn ngữ chính
- Perl
- Star
- 64
- Fork
- 6
- Merge trung bình
- 5 giờ 38 phút
- Pull request đã merge (30 ngày)
- 170
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fglock/PerlOnJava
-
area:cpan-port area:unicode bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
fglock/PerlOnJava#1341 ·
-
area:backend area:runtime bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fglock/PerlOnJava#1511 ·
-
area:backend area:cpan-port bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fglock/PerlOnJava#1508 · 1 bình luận ·
-
Port IPC::SysV (low priority) Đang mởarea:cpan-port area:platform enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
fglock/PerlOnJava#1507 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fglock/PerlOnJava#1506 ·
Tất cả issue của fglock/PerlOnJava
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
documentation Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
trizen/youtube-viewer#456 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
connectivity Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100