Skip to content

fix: parse indirect constructors with fully-qualified class names #1166

Description

@fglock

Summary

PerlOnJava rejects a valid indirect-object constructor expression when the
class is fully qualified and its result is immediately used for a method call.
This prevents Argv 1.28 from loading on non-Windows platforms even though the
affected helper is never executed.

Minimal reproducer

sub construct {
    my %pid_tree = new Win32::Process::Info->Subprocesses(1);
}

print "compiled\\n";

Expected behavior

Perl 5.42 compiles and prints:

compiled

The Win32::Process::Info module need not be installed because the subroutine
body is not executed.

Actual behavior

Both the JVM and interpreter backends fail at compile time:

syntax error near "Win32::Process"

with exit status 255.

CPAN impact

Argv 1.28 failed in CPAN tester run 20260827-102602-1611 while loading the
same construct from its Win32-only Argv::Win32Utils helper. The distribution
is pure Perl and its complete upstream test (test.pl) passes under system
Perl: 11 tests, Result: PASS.

Likely cause

The indirect-object parsing logic treats an unknown fully-qualified invocant
followed by parenthesized arguments as an ambiguous direct-call form and
rejects it. Perl accepts new Class::Name->method(...) as an indirect-object
constructor expression, including when the class is not loaded yet.

Impact

Platform-specific or optional code can make an otherwise usable module fail to
compile on every platform. This also affects applications that use legacy
Perl indirect-object constructor syntax with fully-qualified class names.

Acceptance criteria

  • The minimal reproducer compiles on both backends without loading the Win32
    module.
  • Preserve parsing of new Class::Name->method(...) as an indirect-object
    constructor expression.
  • Argv 1.28 loads and its upstream test can progress past this parser error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions