fix: require/do trailing value & CPANPLUS jcpan bootstrap#750
Open
fglock wants to merge 6 commits into
Open
Conversation
…preter) Perl require expects a defined scalar from the compilation unit trailing statement. - Clone CompilerOptions for nested JVM subs (EmitSubroutine) and lazy named subs (SubroutineParser); clear require/do flags on eval-string compilations (EmitEval, RuntimeCode eval clones). - Track require/do outer apply-body with JavaClassInfo; EmitBlock evaluates the unit final statement in the caller-effective context; LargeBlockRefactorer refuses whole-block refactoring of that outer require/do root. - BytecodeCompiler: when compiling a require unit, if JVM left currentCallContext as RUNTIME, still emit the outer block last statement in scalar/caller context (mirrors EmitBlock). - ModuleOperators.doFile: if require of a compilation unit returns an empty RuntimeList but $@ is still empty before success cleanup, treat as success (Configure → Config ⇄ Backend circular BEGIN chain). - PerlLanguageProvider: set compilationUnitCallerContext for scalar require loads; ancillary CompilerOptions / ConstantFoldingVisitor updates from the investigation. Documentation: add dev/modules/cpanplus.md (full jcpan parity plan including remaining BUILD_PL/SQLite/formatting gaps) and refresh dev/modules/README.md. Generated with Composer (https://cursor.com/) Co-Authored-By: Composer <noreply@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Repair CPANPLUS-style patterns: BUILD_PL-/stat-era ALLCAPS must not route through filehandle-slot parsing when followed by -> or backed by package subs. Narrow multi-dot lexer splits to bare use/no VERSION via parseOptionalPerlBareUseVersion so module imports keep parseOptionalPackageVersion. Delegate version.pm tuple/decimal normalization to normalizeVersionForPerlModule; align numify fractional-slot padding. Add regression tests; refresh dev/modules/cpanplus.md (full jcpan PASS, t/031 done). Co-authored-by: Cursor <cursoragent@cursor.com>
PerlOnJava left $!/$^E undef on some failure paths; $! + 0 warned under warnings. jcpan CPANPLUS is clean TAP after rebuilding shadowJar. Update dev/modules/cpanplus.md: File::Copy resolved, roadmap item 5 done. Co-authored-by: Cursor <cursoragent@cursor.com>
The $^A–$^Z bootstrap left $^E as a plain undef global; stock File::Copy uses $^E + 0 and warned under use warnings. - Non-Windows: reuse the same ErrnoVariable as $! (perlvar). - Windows: separate ErrnoVariable so ($!,$^E)= restores both independently. Revert File::Copy.pm to upstream ($! + 0, $^E + 0); add errno_caret_e_defined.t; refresh dev/modules/cpanplus.md. Co-authored-by: Cursor <cursoragent@cursor.com>
02923fb to
31a63b0
Compare
- Embed parse-time CODeref snapshots via registerCompiledCodeRef only outside local *Glob::name CODE shadow scopes (tracked from RuntimeGlob::dynamicSaveState), cloning the wrapper so pooled sites keep the displaced RuntimeCode when the canonical glob container is mutated (op/symbolcache.t). - Anonymize declared package CVs orphaned by *Glob = anon-sub or stash delete so B::GV->NAME matches Perl (op/stash.t / uni/stash.t). Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
require/do: stopcompilationUnitFromRequireOrDofrom leaking into nested JVM/lazy-sub compilations, reset it on nested eval compilations, and teach the bytecode interpreter outer block to scalarize the last statement when JVM passesRUNTIMEas the call context. Skip refactoring the outermostrequire/doblock inLargeBlockRefactorerwhen it would drop the tail return path.ModuleOperators.doFile: defensive truth when arequireload returns an emptyRuntimeListbut$@is still empty inside the$@probe window (fixesConfigure⇄CPANPLUS::Config⇄Backendcircular BEGIN behavior).&sub(...)call sites:SubroutineParserattachesparseTimeCodeRefwhen parse already saw a real callable (not a baresub name;forward stub), soBytecodeCompilerconstant-pools the CV after neighbouringuse/nohas deleted the stash entry—matches Perl’s pinned-CV behaviour (seesrc/test/resources/unit/pr694_core_regressions.t) without breaking post-deleteeval(seeeval_after_stash_delete.t).dev/modules/cpanplus.md— full rationale plus a roadmap with detailed next steps toward./jcpan -t CPANPLUSparity (t/031 DBIx::Simple, t/20can_load/local *, harness re-run, routine verification).Test plan
maketimeout 120 ./jperl src/test/resources/unit/pr694_core_regressions.ttimeout 120 ./jperl src/test/resources/unit/eval_after_stash_delete.t./jperlsmoke:PERL5LIB=…/blib/lib:…/blib/arch:… ./jperl -e 'require CPANPLUS::Config't/:./jperl -e 'require "./inc/conf.pl"'with matchingPERL5LIBtimeout 3600 ./jcpan -t CPANPLUS— refresh snapshot after this PR; remaining gaps tracked indev/modules/cpanplus.md(t/031 SQLite, t/20 Dist::MM, etc.)Where to continue
See
dev/modules/cpanplus.md— “Roadmap:./jcpan -t CPANPLUS— detailed next steps” (sections 0–6) and the progress table.