Avoid false unavailable warnings for file-scope lexical subs
Maintainer thường phản hồi trong vòng 1 ngày
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
- 35/100
Hướng nghiên cứu
Start with the warning condition in src/main/java/org/perlonjava/frontend/parser/SubroutineParser.java near the lexicalSubStorageName check, which emits the unavailable-lexical-sub warning for named subs. Run the minimal reproducer with ./jperl and ./jperl --interpreter to confirm the false warning. Done means that output is just 1 on both backends, a regression test covers file-scope lexical subs, and true out-of-scope diagnostics still fire.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
PerlOnJava emits a false Subroutine "&NAME" is not available closure warning when a package named sub calls a file-scope lexical sub. The lexical sub remains available and the call succeeds, but the warning makes callers that capture warnings fail. This affects both the JVM and interpreter backends.
Minimal reproducer
use feature 'lexical_subs';
no warnings 'experimental::lexical_subs';
use warnings;
my sub helper { 1 }
sub package_sub { helper() }
print package_sub(), "\n";
System Perl prints 1 without a closure warning. PerlOnJava prints Subroutine "&helper" is not available at -e line 1. and then prints 1. This reproduces on both ./jperl and ./jperl --interpreter.
Root cause
src/main/java/org/perlonjava/frontend/parser/SubroutineParser.java emits the unavailable-lexical-sub warning while constructing a named sub when it finds a referenced lexical sub in the outer symbol table. The warning condition checks that the current sub has a name and that the lexical sub is referenced, but it does not distinguish a file-scope lexical sub from a lexical sub whose lifetime is tied to an enclosing runtime invocation. The file-scope case is valid and must not warn.
The reproducer still invokes the lexical sub and returns the expected value; the defect is the warning classification. The current behavior is visible around the lexicalSubStorageName check in SubroutineParser (master source at report time: 506371c134837d026687b1958c856edb3c6f70e4).
CPAN evidence
- Distribution:
Perl-Critic-Policy-ControlStructures-ProhibitEmptyConditionalBlocks0.001 - CPAN random run:
20261121-154046-78188 - Failing test:
t/main.t,Test::Warningsassertionno (unexpected) warnings (via done_testing); 1 of 30 tests failed. - The captured warnings came from valid file-scope lexical subs in Perl's bundled
_charnames.pm:populate_txt,alias, andalias_file. - The archived system-Perl oracle used Perl 5.42.2 and passed the target distribution's full suite: 18 files, 30 tests.
- The current local reproducer was also checked on system Perl 5.34.1, where it prints
1without a warning. The local PerlOnJava checkout is commit506371c134837d026687b1958c856edb3c6f70e4, Java 24.0.2, macOS 26.7.3 arm64.
Related issue
Issue #1511 reports the same warning text in a Moo role-composition scenario, but its confirmed cause was caller-package propagation through generated eval and dynamic require. This report is an independent warning defect: it reproduces without Moo or role composition and with a plain file-scope lexical sub.
Acceptance criteria
- The minimal reproducer prints
1without warnings on both PerlOnJava backends. - A focused project-owned regression test covers file-scope lexical subs referenced from named package subs and is validated with system Perl first.
- The CPAN distribution's
t/main.twarning assertion passes on both backends. - Existing diagnostics for lexical subs that truly cannot outlive an enclosing runtime scope remain intact.
- Ngôn ngữ chính
- Perl
- Star
- 67
- Fork
- 8
- Merge trung bình
- 4 giờ 36 phút
- Pull request đã merge (30 ngày)
- 123
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc 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:runtime bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fglock/PerlOnJava#2164 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cpan-port bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fglock/PerlOnJava#2153 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cpan-port area:parser bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fglock/PerlOnJava#2137 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:backend area:cpan-port area:runtime bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fglock/PerlOnJava#2071 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:runtime documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fglock/PerlOnJava#1579 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fglock/PerlOnJava
Issue tương tự
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksĐang mởteam-cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 93/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
inverse-inc/packetfence#9728 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(char-create): show the real reason a character is refusedCó thể đã có người làm @baphomello đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày