From c5327cb77526e4e4c7bb83e24be20ac48e85b1fa Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 6 Jun 2022 14:52:15 +1000 Subject: fix no bareword_filehandles for method calls as first argument of LSTOPs The original code in toke.c tried to detect a bareword as a file handle during tokenization rather than once the expression following the LSTOP has been parsed. I've moved the checking for a bareword filehandle to the ck functions for each OP in most cases, which covers most OPs except for LSTOPs like print. To handle that I've added a check in newGVREF(). This means in most cases that the error is produced just as the bareword would normally be wrapped in an OP_RV2GV. The special case for that is readline(), which does it's own rv2gv() at runtime, but it does have a ck function which can check for the bareword handle. --- toke.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index e336c6a483..7d785a8771 100644 --- a/toke.c +++ b/toke.c @@ -7622,12 +7622,6 @@ 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 && !c.cv - && !FEATURE_BAREWORD_FILEHANDLES_IS_ENABLED) { - no_bareword_filehandle(PL_tokenbuf); - } - /* If not a declared subroutine, it's an indirect object. */ /* (But it's an indir obj regardless for sort.) */ /* Also, if "_" follows a filetest operator, it's a bareword */ -- cgit v1.2.1