Moo role composition loses lexical-sub closures
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
- 45/100
Hướng nghiên cứu
The issue is in the JVM backend's handling of lexical closures during Moo role composition. Start by examining the minimal reproducer in the issue body to understand the failure. Look at how PerlOnJava implements subroutine aliasing and environment preservation, particularly in the Moo::Role composition path. The fix must ensure lexical pads are retained when methods are copied. Run the provided CPAN test for CXC::Form::Tiny::Plugin::OptArgs2 to verify the resolution.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
PerlOnJava loses the lexical-sub closure when a Moo role copies a method into a consuming class. This breaks Form::Tiny plugin metaclasses and causes CXC::Form::Tiny::Plugin::OptArgs2 0.12 to fail during class construction.
Minimal reproducer
The following program prints 42 under system Perl:
package R; use Moo::Role; my sub helper { 41 }; sub role_method { helper()+1 }; package C; use Moo; with "R"; package main; print C->new->role_method, "\\n";
On the JVM backend it prints the expected 42 but also emits:
Subroutine "&helper" is not available
The warning is emitted from the role-composed method after it has been installed in C. This demonstrates that the method body retained its call to the lexical helper but lost the lexical environment that should contain helper. System Perl exits successfully without the warning.
CPAN evidence
The CPAN regression run 20260924-085657-82687 reported CXC::Form::Tiny::Plugin::OptArgs2 0.12 failing in t/OptArgs.t, t/inherit.t, t/nested.t, and t/required.t. The failure is:
Can.t locate object method "new" via package "My::Form"
The same run emitted unavailable-lexical-sub diagnostics for CXC::Form::Tiny::Plugin::OptArgs2::Meta methods referencing croak, _match_inherit_optargs, and parse_inherit_matches. t/optargs_opts.t passed.
With the exact dependency blibs and load order, the five substantive upstream test files pass under system Perl: 15 tests, all successful. Therefore this is attributable to PerlOnJava rather than upstream behavior or missing prerequisites.
Backend results
- JVM backend: minimal reproducer emits the unavailable lexical-sub diagnostic; the CPAN test reaches My::Form->new and fails.
- Interpreter backend: the same dependency stack currently fails earlier while loading the Moo/Role::Tiny implementation with a strict-refs error involving Form::Tiny::Error::with. It does not invalidate the JVM reproducer; interpreter parity should be checked separately.
Likely ownership
The primary defect is in closure/environment preservation when role composition aliases or installs a subroutine into another package. A method containing a lexical-sub call must retain the defining lexical pad after Moo::Role composition. The downstream missing constructor is a consequence of the Form::Tiny metaclass/class role setup failing after these composed methods cannot resolve their lexical helpers.
Acceptance criteria
- The minimal Moo role reproducer passes on the JVM backend without an unavailable-lexical-sub diagnostic.
- CXC::Form::Tiny::Plugin::OptArgs2 0.12 passes its five substantive test files on the JVM backend.
- The interpreter backend has an explicit parity result for the same lexical-role-closure case.
- Add a permanent project-owned regression test; verify it with system Perl first and on both PerlOnJava backends after the fix.
No upstream tests were modified.
- 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: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 ·
-
bug enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fglock/PerlOnJava#1502 ·
Tất cả issue của fglock/PerlOnJava
Issue tương tự
-
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
-
Common US ingredient names are not recognized, so about 12.4k US products miss an allergen warning Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
openfoodfacts/openfoodfacts-server#14657 · 4 bình luận ·