@@ -180,6 +180,7 @@ static const char ident_var_zero_multi_digit[] = "Numeric variables with more th
180180#define IDFIRST_ONLY (1 << 3)
181181#define STOP_AT_FIRST_NON_DIGIT (1 << 4)
182182#define CHECK_ONLY (1 << 5)
183+ #define CHECK_UNARY (1 << 6)
183184
184185#ifdef DEBUGGING
185186static const char * const lex_state_names [] = {
@@ -4746,7 +4747,7 @@ S_intuit_more(pTHX_ char *s, char *e,
47464747 *
47474748 * khw: If what follows can't be an identifier, say it is too
47484749 * long or is $001, then it must be a charclass */
4749- scan_ident (s , tmpbuf , C_ARRAY_END (tmpbuf ), FALSE );
4750+ scan_ident (s , tmpbuf , C_ARRAY_END (tmpbuf ), 0 );
47504751 len = strlen (tmpbuf );
47514752
47524753 /* khw: This only looks at global variables; lexicals came
@@ -5606,8 +5607,7 @@ yyl_dollar(pTHX_ char *s)
56065607 || memCHRs ("{$:+-@" , s [2 ])))
56075608 {
56085609 PL_tokenbuf [0 ] = '@' ;
5609- s = scan_ident (s + 1 , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ),
5610- FALSE);
5610+ s = scan_ident (s + 1 , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), 0 );
56115611 S_warn_expect_operator (aTHX_ "Array length" , s , POP_OLDBUFPTR );
56125612 if (!PL_tokenbuf [1 ])
56135613 PREREF (DOLSHARP );
@@ -5617,7 +5617,7 @@ yyl_dollar(pTHX_ char *s)
56175617 }
56185618
56195619 PL_tokenbuf [0 ] = '$' ;
5620- s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), FALSE );
5620+ s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), 0 );
56215621 S_warn_expect_operator (aTHX_ "Scalar" , s , POP_OLDBUFPTR );
56225622 if (!PL_tokenbuf [1 ]) {
56235623 if (s == PL_bufend )
@@ -6282,7 +6282,7 @@ yyl_star(pTHX_ char *s)
62826282 POSTDEREF (PERLY_STAR );
62836283
62846284 if (PL_expect != XOPERATOR ) {
6285- s = scan_ident (s , PL_tokenbuf , C_ARRAY_END (PL_tokenbuf ), TRUE );
6285+ s = scan_ident (s , PL_tokenbuf , C_ARRAY_END (PL_tokenbuf ), CHECK_UNARY );
62866286 PL_expect = XOPERATOR ;
62876287 force_ident (PL_tokenbuf , PERLY_STAR );
62886288 if (!* PL_tokenbuf )
@@ -6330,7 +6330,7 @@ yyl_percent(pTHX_ char *s)
63306330 POSTDEREF (PERLY_PERCENT_SIGN );
63316331
63326332 PL_tokenbuf [0 ] = '%' ;
6333- s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), FALSE );
6333+ s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), 0 );
63346334 pl_yylval .ival = 0 ;
63356335 if (!PL_tokenbuf [1 ]) {
63366336 PREREF (PERLY_PERCENT_SIGN );
@@ -6867,7 +6867,8 @@ yyl_ampersand(pTHX_ char *s)
68676867 }
68686868
68696869 PL_tokenbuf [0 ] = '&' ;
6870- s = scan_ident (s - 1 , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), TRUE);
6870+ s = scan_ident (s - 1 , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ),
6871+ CHECK_UNARY );
68716872 pl_yylval .ival = (OPpENTERSUB_AMPER <<8 );
68726873
68736874 if (PL_tokenbuf [1 ])
@@ -6952,7 +6953,7 @@ yyl_snail(pTHX_ char *s)
69526953 if (PL_expect == XPOSTDEREF )
69536954 POSTDEREF (PERLY_SNAIL );
69546955 PL_tokenbuf [0 ] = '@' ;
6955- s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), FALSE );
6956+ s = scan_ident (s , PL_tokenbuf + 1 , C_ARRAY_END (PL_tokenbuf ), 0 );
69566957 S_warn_expect_operator (aTHX_ "Array" , s , POP_OLDBUFPTR );
69576958 pl_yylval .ival = 0 ;
69586959 if (!PL_tokenbuf [1 ]) {
@@ -10757,7 +10758,7 @@ Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STR
1075710758 * specific variable name.
1075810759 */
1075910760STATIC char *
10760- S_scan_ident (pTHX_ char * s , char * dest , char * dest_end , bool chk_unary )
10761+ S_scan_ident (pTHX_ char * s , char * dest , char * dest_end , U32 flags )
1076110762{
1076210763 PERL_ARGS_ASSERT_SCAN_IDENT ;
1076310764
@@ -10768,6 +10769,8 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary)
1076810769 char * const e = dest_end - 3 ; /* two-character token, ending NUL */
1076910770 bool is_utf8 = cBOOL (UTF );
1077010771 line_t orig_copline = 0 , tmp_copline = 0 ;
10772+ const bool chk_unary = (flags & CHECK_UNARY );
10773+
1077110774
1077210775 if (isSPACE (* s ) || !* s )
1077310776 s = skipspace (s );
0 commit comments