Skip to content

Phase 11: DateTime dependency fixes and map/grep @_ access - #342

Merged
fglock merged 15 commits into
masterfrom
feature/cpan-client-phase-11
Mar 20, 2026
Merged

Phase 11: DateTime dependency fixes and map/grep @_ access#342
fglock merged 15 commits into
masterfrom
feature/cpan-client-phase-11

Conversation

@fglock

@fglock fglock commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR continues Phase 11 of CPAN client support, focusing on DateTime module dependencies.

Fixes

  • map/grep blocks accessing outer @_: Code like map { $_[0] } inside a subroutine now correctly accesses the outer @_ instead of an empty array
  • B module introspection: B::CV::GV now uses Sub::Util::subname to report actual subroutine names, enabling proper namespace::autoclean behavior
  • Scalar::Util::blessed: Now returns undef for unblessed references (was incorrectly returning class name)
  • GLOBREFERENCE scalar dereference: $$globref now returns the glob itself (from previous commits)

DateTime Status

DateTime now works in pure Perl mode with manual patches:

PERL_DATETIME_PP=1 ./jperl -MDateTime -e '
  my $dt = DateTime->new(year => 2024, month => 3, day => 15);
  print $dt->ymd;  # 2024-03-15
'

Design Doc Updates

  • Added next steps for DateTime: investigate namespace::autoclean behavior difference vs system Perl, enable XS fallback to DateTime.java
  • Trimmed old progress reports (884→172 lines) while preserving current work

Test plan

  • make passes all unit tests
  • map/grep with @_ access works correctly
  • DateTime loads in pure Perl mode

Generated with Devin

fglock and others added 15 commits March 19, 2026 22:53
Changes:
- BHooksEndOfScope: Implement file-level callback tracking instead of
  runtime scope-based defer. Callbacks now fire when the file that
  called on_scope_end finishes loading (via doFile/require).
- ModuleOperators: Call beginFileLoad/endFileLoad to track file loading
  and trigger on_scope_end callbacks at the right time.
- B.pm: Add perlstring() function and Exporter support for modules like
  Specio that need to convert strings to Perl source representation.

This fixes namespace::clean not working properly with PerlOnJava because
callbacks were firing when import() returned instead of when the calling
module finished loading.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Document B::Hooks::EndOfScope rewrite and namespace::clean fixes.
Note remaining DateTime dependency chain issues.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
In Perl, dereferencing a glob reference as a scalar returns the glob
itself, not the scalar slot. This fixes Role::Tiny's _install_methods
which uses this pattern to extract overload method names.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Mark Role::Tiny issue as FIXED
- Add IO::Dir/File::stat bytecode issue as remaining blocker
- Document Perl semantics for glob vs glob reference dereferencing

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- map { $_[0] } now correctly accesses the outer subroutine's @_
- grep { $_[0] } and other list operators (all, any) also fixed
- Scalar::Util::blessed now returns undef for unblessed refs

The fix passes the enclosing subroutine's @_ to the map/grep block
code, so that $_[0], $_[1] etc. refer to the outer @_ rather than
an empty array. This matches Perl's semantics where blocks are not
full subroutines and share the caller's @_.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- B::CV::GV now uses Sub::Util::subname to get the real sub name
- B::CV::STASH also uses Sub::Util::subname for package information
- This enables namespace::autoclean and other introspection modules
  to correctly identify where code references were defined

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Document map/grep @_ access fix
- Document B module introspection improvements
- Document DateTime pure Perl mode working with patches
- Document remaining namespace::autoclean issues

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Step 1: Investigate namespace::autoclean behavior difference vs system Perl
- Step 2: Enable XS fallback to DateTime.java implementation

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Reduced from 884 lines to 172 lines
- Condensed phases 1-9 into summary table
- Kept module availability reference tables
- Kept Safe/Opcode limitation explanation
- Preserved Phase 11 (active) with full details and next steps

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add null checks in beginFileLoad/endFileLoad for cases where
  fileName is null (e.g., loading from filehandles via @inc hooks)
- Simplify B::CV->GV and B::CV->STASH to always return __ANON__/main
  since Sub::Util::subname cannot reliably track installed names

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
When code is installed via glob assignment (*pkg::name = $code),
update the RuntimeCode's packageName/subName fields to reflect
the installed name. This fixes namespace::autoclean incorrectly
removing methods installed via symbolic glob assignment.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…king

- Document that Sub::Util::subname now returns installed glob name
- Mark DateTime core functionality as working (no PERL_DATETIME_PP needed)
- Document remaining issue: Try::Tiny needed for timezone support

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…orts still broken

- Glob assignment fix works for DateTime::PP methods
- Exporter imports still cleaned because aliases share RuntimeCode
- Document why we can't easily fix Exporter case
- Next steps: investigate Perl behavior, consider namespace::autoclean stub

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The fix to update packageName/subName on glob assignment broke
mro/next_edgecases.t - Perl's behavior is that glob assignment
does NOT change subname, and next::method relies on this.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock
fglock merged commit 9363ed0 into master Mar 20, 2026
2 checks passed
@fglock
fglock deleted the feature/cpan-client-phase-11 branch March 20, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant