Conversation
…orted forward declarations - Fixed bug in Exporter.exportToLevel() where packageScalar object was used instead of packageName string when looking up export arrays - Added sourcePackage field to RuntimeCode to track original package of imported forward declarations - Updated RuntimeCode.apply() to check sourcePackage AUTOLOAD when imported forward declarations are called - This enables proper AUTOLOAD resolution for modules that export forward-declared functions (e.g., Image::ExifTool) Fixes: Undefined subroutine errors when calling imported forward-declared functions
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
This PR fixes the "Undefined subroutine" error when calling imported forward-declared functions that use AUTOLOAD.
Changes
1. Fixed Package Name Bug in Exporter.java
exportToLevel(), the code was usingpackageScalar(RuntimeScalar object) instead ofpackageName(string) when looking up export arrayspackageNamefor correct namespace resolution2. Added AUTOLOAD Support for Imported Forward Declarations
RuntimeCode.javasourcePackagefield to track the original package of imported forward declarationsapply()method to check for AUTOLOAD in the source package when an imported forward declaration is called3. Updated Import Mechanism
Exporter.javaimportFunction()to setsourcePackagewhen importing undefined functionsProblem Solved
When a module like
Image::ExifToolexports forward-declared functions (e.g.,GetAllTags) that are later defined via AUTOLOAD, calling these functions after import would fail with "Undefined subroutine" errors. This was because:Testing
autoload.ttest validates AUTOLOAD functionalityExample Use Case
This fix enables modules like ExifTool to work correctly:
Note
While testing with ExifTool, we discovered a separate "Method too large" issue when compiling ExifTool's large data structures. Once that issue is resolved, the import mechanism will work correctly with these fixes in place.