Skip to content

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Dec 18, 2025

Fixes #93

Problem

When a subroutine like sub Encode exists in the current package, qualified calls like Encode::is_utf8() were incorrectly being resolved to the local subroutine instead of the external package.

This caused ExifTool to fail with:

PerlCompilerException: Not enough arguments for Image::ExifTool::Encode

Root Cause

The parser was checking for lexical subs and package sub overrides before checking if :: follows the identifier. So when parsing Encode::is_utf8, it would see that XYZ::Encode exists and treat Encode as a subroutine call.

Fixes

1. ParsePrimary.java

Don't treat an identifier as a lexical sub call if :: follows. Encode::is_utf8 is a qualified name to the Encode package, not a call to local sub Encode.

2. OperatorParser.java

Parse bareword module names in require directly using parseSubroutineIdentifier() instead of going through the expression parser. This prevents require Encode from treating Encode as a subroutine call when a sub with the same name exists in the current package.

Test Case

package XYZ;
sub Encode ($$) {}
require Encode;
Encode::is_utf8("");

This now works correctly.

…n current package

Fixes #93

When a subroutine like 'sub Encode' exists in the current package, qualified
calls like 'Encode::is_utf8()' were incorrectly being resolved to the local
subroutine instead of the external package.

Two fixes:

1. ParsePrimary.java: Don't treat an identifier as a lexical sub call if '::'
   follows. 'Encode::is_utf8' is a qualified name to the Encode package, not
   a call to local 'sub Encode'.

2. OperatorParser.java: Parse bareword module names in 'require' directly
   using parseSubroutineIdentifier() instead of going through the expression
   parser. This prevents 'require Encode' from treating 'Encode' as a
   subroutine call when a sub with the same name exists in the current package.
   Quote-like operators (q, qq, qw, etc.) are excluded so 'require q(file)'
   still works.

Test case that now works:
  package XYZ;
  sub Encode ($$) {}
  require Encode;
  Encode::is_utf8("");
@fglock fglock force-pushed the fix/qualified-subroutine-name-resolution branch from 8d72183 to 609f04d Compare December 18, 2025 14:32
@fglock fglock merged commit 770c071 into master Dec 18, 2025
2 checks passed
@fglock fglock deleted the fix/qualified-subroutine-name-resolution branch December 18, 2025 14:39
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.

Compile of ExifTool fails

2 participants