summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2021-12-11 13:14:27 +0000
committerKarl Williamson <khw@cpan.org>2021-12-16 07:56:21 -0700
commit5f5ca502c6f3b230ff3faa1a80c6009715f9970c (patch)
tree64888a4d70bb35e3a6b17a8d4aae0c1a3a978212
parent999b4e2f823bb3637377cedf1548ce7eb27ab6c0 (diff)
downloadperl-5f5ca502c6f3b230ff3faa1a80c6009715f9970c.tar.gz
Also fix paren-less calls of subs where a filehandle could be
If a sub exists, it takes precedence over the filehandle interpretation even without the parens: $ perl -le 'sub foo { "bar" } print foo;' bar
-rw-r--r--t/lib/feature/bareword_filehandles3
-rw-r--r--toke.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/t/lib/feature/bareword_filehandles b/t/lib/feature/bareword_filehandles
index 38f8d6530c..a3604770d4 100644
--- a/t/lib/feature/bareword_filehandles
+++ b/t/lib/feature/bareword_filehandles
@@ -490,6 +490,9 @@ use feature "say";
no feature "bareword_filehandles";
sub foo {}
print foo();
+print foo;
say foo();
+say foo;
-x foo();
+-x foo;
EXPECT
diff --git a/toke.c b/toke.c
index 75dcee5beb..c1d1f76eb0 100644
--- a/toke.c
+++ b/toke.c
@@ -7620,7 +7620,7 @@ yyl_just_a_word(pTHX_ char *s, STRLEN len, I32 orig_keyword, struct code c)
s = SvPVX(PL_linestr) + s_off;
if (((PL_opargs[PL_last_lop_op] >> OASHIFT) & 7) == OA_FILEREF
- && !immediate_paren
+ && !immediate_paren && !c.cv
&& !FEATURE_BAREWORD_FILEHANDLES_IS_ENABLED) {
no_bareword_filehandle(PL_tokenbuf);
}