Branch: refs/heads/no-bareword-filehandle-function
Home: https://github.com/Perl/perl5
Commit: 6c18f17a201a892d0d94e1854aedcea105a8bc39
https://github.com/Perl/perl5/commit/6c18f17a201a892d0d94e1854aedcea105a8bc39
Author: Dagfinn Ilmari Mannsåker <[email protected]>
Date: 2021-12-11 (Sat, 11 Dec 2021)
Changed paths:
M t/lib/feature/bareword_filehandles
M toke.c
Log Message:
-----------
Fix function calls being misinterpreted as bareword filehandles
When bareword filehandles are disabled, the parser was interpreting
any bareword as a filehandle, even when immediatey followed by parens:
$ perl -M-feature=bareword_filehandles -le 'print foo()'
Bareword filehandle "foo" not allowed under 'no feature
"bareword_filehandles"' at -e line 1.
While with the feature enabled, it works and prints the value returned
by the function:
$ perl -le 'sub foo { @_ } print foo("bar")'
bar
As for filehandles versus functions, a space before the parens makes
the difference:
$ perl -le 'print STDOUT ("bar")'
bar
$ perl -le 'print STDOUT("bar")'
Undefined subroutine &main::STDOUT called at -e line 1.
This fixes the bug by using the already-existing "immediate_paren"
variable to make it consistent when the feature is disabled.
Fixes #19271