Fix MM->parse_version for fully-qualified VERSION variables#355
Merged
Conversation
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>
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
Fixes the spurious warnings during
jcpan -t DateTime:Problem
MM->parse_version()failed to extract versions from modules that use fully-qualified variable names like: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 useeval "\$$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"jcpan -t DateTimeno longer shows WARNING messagesGenerated with Devin