Skip to content

Fix MM->parse_version for fully-qualified VERSION variables#355

Merged
fglock merged 2 commits into
masterfrom
fix/parse-version-fully-qualified
Mar 23, 2026
Merged

Fix MM->parse_version for fully-qualified VERSION variables#355
fglock merged 2 commits into
masterfrom
fix/parse-version-fully-qualified

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 23, 2026

Summary

Fixes the spurious warnings during jcpan -t DateTime:

Dist::CheckConflicts version 'undef' is not in required range '0.02'
CPAN::Meta::Check version 'undef' is not in required range '0.011'

Problem

MM->parse_version() failed to extract versions from modules that use fully-qualified variable names like:

$Dist::CheckConflicts::VERSION = '0.11';

This pattern is commonly used by modules built with Dist::Zilla.

The root cause was that symbolic dereferencing (${$name}) doesn't work correctly for modules loaded from JAR files in PerlOnJava.

Solution

Changed get_version() to use eval "\$$name" to retrieve the version value instead of ${$name}. This works correctly regardless of how the module is loaded.

Test Plan

  • MM->parse_version() correctly extracts versions for all patterns:
    • $VERSION = "1.23"
    • our $VERSION = "1.23"
    • $Package::VERSION = "1.23"
  • Dist::CheckConflicts now shows version 0.11 (was "undef")
  • CPAN::Meta::Check now shows version 0.018 (was "undef")
  • jcpan -t DateTime no longer shows WARNING messages
  • Unit tests pass

Generated with Devin

fglock and others added 2 commits March 23, 2026 11:12
When namespace::autoclean doesn't clean up Try::Tiny imports (as in
PerlOnJava's stub), modules like DateTime retain 'catch' in their
namespace. This causes issues when indirect object syntax like
'catch { $dt->truncate(...) }' is parsed as '$dt->truncate(...)->catch()'.

The fix detects when catch() is incorrectly invoked as a method (first
argument is a blessed reference instead of CODE) and throws the expected
'Can't locate object method' error, making tests like DateTime's
t/48rt-115983.t pass.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The parse_version function now correctly handles version declarations
like $Package::VERSION = '1.23' which are commonly used by modules
built with Dist::Zilla.

The fix uses eval to retrieve the version value instead of symbolic
dereferencing (${name}), which doesn't work correctly for modules
loaded from JAR files in PerlOnJava.

This eliminates the spurious warnings during 'jcpan -t DateTime':
  Dist::CheckConflicts version 'undef' is not in required range '0.02'
  CPAN::Meta::Check version 'undef' is not in required range '0.011'

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 439e63b into master Mar 23, 2026
2 checks passed
@fglock fglock deleted the fix/parse-version-fully-qualified branch March 23, 2026 11:01
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