Fix bytecode compiler my-extraction and AUTOLOAD with forward declarations#244
Merged
Fix bytecode compiler my-extraction and AUTOLOAD with forward declarations#244
Conversation
… with forward declarations Two fixes: 1. Bytecode compiler (interpreter backend): extract my declarations before short-circuit jumps in &&/||// operators. Previously, 'my $x = expr if COND' left the register as Java null when the condition was false, causing NPEs. Now uses FindDeclarationVisitor to emit the declaration unconditionally before the conditional jump, matching the JVM emitter behavior. 2. Method resolution: forward declarations (sub foo;) no longer prevent AUTOLOAD from being called. Previously, findMethodInHierarchy would find the forward declaration, see it was undefined, and skip to the next class in the hierarchy (bypassing AUTOLOAD). Now it falls through to the AUTOLOAD check for the same class. This fixes ExifTool VerboseInfo and other Writer.pl methods loaded via AUTOLOAD. ExifTool.t: 24/35 tests pass (up from 12/35, test 17 no longer crashes). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
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
Relates to #93
Two fixes that improve ExifTool compatibility from 12/35 to 24/35 passing tests.
1. Bytecode compiler:
myextraction in short-circuit operatorsThe bytecode compiler (interpreter backend) for
&&,||, and//operators now extractsmydeclarations before the short-circuit jump. Previously,my $x = expr if CONDleft the interpreter register as Java null when the condition was false, causing NPEs at runtime.Now uses
FindDeclarationVisitorto emit the declaration unconditionally before the conditional jump, matching the JVM emitter behavior that was fixed in PR #243.2. AUTOLOAD with forward declarations
Forward declarations (
sub foo;) no longer prevent AUTOLOAD from being called during method dispatch. Previously,findMethodInHierarchywould find the forward declaration, see it was undefined, andcontinueto the next class in the hierarchy — bypassing the AUTOLOAD check for the current class.Now it falls through to the AUTOLOAD check for the same class. This fixes ExifTool's
VerboseInfoand other Writer.pl methods that are loaded via AUTOLOAD.ExifTool.t results
Before: 12/35 tests pass, crashes at test 17 (VerboseInfo not found)
After: 24/35 tests pass, all 35 tests run to completion
Remaining 11 failures are mostly related to missing File System metadata (FileSize, FileModifyDate, FilePermissions).
Test plan
./gradlew testpasses (all unit tests)my $x = expr if CONDworks in both JVM and interpreter pathsGenerated with Devin