Summary
A subroutine installed through a typeglob assignment at runtime is not invoked
when it is the first argument of an unparenthesized print call.
Reproducer
no strict 'refs';
*bar = sub { 'glob-installed' };
print bar(), "\n";
Expected behavior
Perl 5.42 prints:
Actual behavior
Both PerlOnJava backends exit successfully but print only the newline.
Investigation notes
The typeglob assignment does install a callable subroutine. The following
forms work in both backends:
my $value = bar();
print $value, "\n";
my $name = 'bar';
print &$name(), "\n";
print 'prefix=', bar(), "\n";
The failure is therefore not general dynamic-sub lookup. It is a narrow
parse/emission problem for the bareword call as the leading argument of the
unparenthesized print form. PerlOnJava also rejects the otherwise valid
parenthesized spelling print(bar(), "\n") with a syntax error, which may be
related.
Impact
This breaks runtime method/function registration patterns used by plugin
systems, DSLs, generated code, and legacy Perl that installs subs by glob
assignment. The silent empty result is more hazardous than a compile-time
failure.
Acceptance criteria
- The reproducer prints
glob-installed on both backends.
- The parenthesized
print(bar(), "\\n") spelling is accepted and has the
same result as Perl.
- Preserve dynamic lookup: a sub installed after compilation must remain
callable at the call site.
Summary
A subroutine installed through a typeglob assignment at runtime is not invoked
when it is the first argument of an unparenthesized
printcall.Reproducer
Expected behavior
Perl 5.42 prints:
Actual behavior
Both PerlOnJava backends exit successfully but print only the newline.
Investigation notes
The typeglob assignment does install a callable subroutine. The following
forms work in both backends:
The failure is therefore not general dynamic-sub lookup. It is a narrow
parse/emission problem for the bareword call as the leading argument of the
unparenthesized
printform. PerlOnJava also rejects the otherwise validparenthesized spelling
print(bar(), "\n")with a syntax error, which may berelated.
Impact
This breaks runtime method/function registration patterns used by plugin
systems, DSLs, generated code, and legacy Perl that installs subs by glob
assignment. The silent empty result is more hazardous than a compile-time
failure.
Acceptance criteria
glob-installedon both backends.print(bar(), "\\n")spelling is accepted and has thesame result as Perl.
callable at the call site.