Allow Moo constant closures capturing lexical values
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start with Moo/_Utils.pm around lines 216 and 221, then trace the BEGIN block and its string eval into PerlOnJava's constant-subroutine and lexical-capture handling. Reproduce with use Moo; on both backends and compare with standard Perl. Done means Moo loads successfully without the invalid constant-closure diagnostic and the MooX::Options::Actions basic test runs.
Written by the indexing model from the issue text.
Description
Summary
PerlOnJava cannot compile Moo because it rejects the generated constant closure in Moo::_Utils. This prevents MooX::Options::Actions 0.001 from loading, even though the complete upstream suite passes under standard Perl.
Reproduction
The failure was found in CPAN random run 20260921-124328-13959 while testing MooX::Options::Actions 0.001. Its dependency chain includes MooX::Options 4.103 and Moo.
The smallest reproducer is:
use Moo;
On both the JVM backend and the interpreter backend, PerlOnJava reports:
Constants from lexical variables potentially modified elsewhere are no longer permitted
at Moo/_Utils.pm line 216.
BEGIN failed--compilation aborted at Moo/_Utils.pm line 221
Compilation failed in require
The error is raised while compiling Moo's BEGIN block that constructs a constant helper from a lexical expression involving ${^GLOBAL_PHASE}. Standard Perl accepts and loads this code.
CPAN evidence
The standard-Perl oracle passes the upstream distribution:
t/basic.t .............. ok
All tests successful.
Files=2, Tests=8
Result: PASS
Under PerlOnJava, t/author-pod-syntax.t is skipped as intended, but t/basic.t aborts before running any tests:
t/basic.t ..............
Dubious, test returned 255
No subtests run
Files=2, Tests=0
The dependency installation completed successfully. This is not a missing dependency or timeout; the failure occurs in PerlOnJava's bundled Moo implementation during compilation.
Expected behavior
PerlOnJava should accept Moo's generated constant subroutine and load Moo successfully. The diagnostic should not be emitted for the valid lexical-closure pattern used by current Moo releases.
Suspected area
Compiler handling of constant subroutines and lexical capture analysis, especially code generated by string eval inside a BEGIN block. The implementation appears to reject a pattern that standard Perl permits when a lexical value is captured by a constant subroutine.
Environment and scope
- Distribution:
MooX::Options::Actions0.001 - Dependencies:
MooX::Options4.103,Moo - PerlOnJava backends: JVM and interpreter
- PerlOnJava reports Perl 5.044001
- Standard Perl oracle: Perl 5.42.2 on macOS
- Native/XS code in the affected distribution: none
- Reverse-dependency analysis: not applicable; this is a pure-Perl compatibility failure
This failure is separate from the unrelated Ambiguous call resolved as CORE::try() warnings emitted by the same run.
- Dominant language
- Perl
- Stars
- 64
- Forks
- 6
- Avg merge
- 5h 38m
- Merged PRs (30d)
- 170
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fglock/PerlOnJava
-
area:cpan-port area:unicode bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
fglock/PerlOnJava#1341 ·
-
area:backend area:runtime bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1511 ·
-
area:backend area:cpan-port bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1508 · 1 comment ·
-
area:cpan-port area:platform enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
fglock/PerlOnJava#1507 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1506 ·
All issues in fglock/PerlOnJava
Similar issues
-
documentation Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
trizen/youtube-viewer#456 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
connectivity Open
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Common US ingredient names are not recognized, so about 12.4k US products miss an allergen warning Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
openfoodfacts/openfoodfacts-server#14657 · 4 comments ·