This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make the warning "interpreted as function" a bit less annoying,
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index 89bb87b..96b33cb 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2024,7 +2024,7 @@ S_scan_const(pTHX_ char *start)
                    *d++ = NATIVE_TO_NEED(has_utf8,*s++);
            }
            else if (s[2] == '{' /* This should match regcomp.c */
-                    || ((s[2] == 'p' || s[2] == '?') && s[3] == '{'))
+                   || (s[2] == '?' && s[3] == '{'))
            {
                I32 count = 1;
                char *regparse = s + (s[2] == '{' ? 3 : 4);
@@ -2646,7 +2646,8 @@ S_intuit_method(pTHX_ char *start, GV *gv, CV *cv)
      */
 
     if (*start == '$') {
-       if (gv || PL_last_lop_op == OP_PRINT || isUPPER(*PL_tokenbuf))
+       if (gv || PL_last_lop_op == OP_PRINT || PL_last_lop_op == OP_SAY ||
+               isUPPER(*PL_tokenbuf))
            return 0;
 #ifdef PERL_MAD
        len = start - SvPVX(PL_linestr);
@@ -2922,7 +2923,7 @@ S_readpipe_override(pTHX)
                && GvCVu(gv_readpipe) && GvIMPORTED_CV(gv_readpipe))
            ||
            ((gvp = (GV**)hv_fetchs(PL_globalstash, "readpipe", FALSE))
-            && (gv_readpipe = *gvp) != (GV*)&PL_sv_undef
+            && (gv_readpipe = *gvp) && isGV_with_GP(gv_readpipe)
             && GvCVu(gv_readpipe) && GvIMPORTED_CV(gv_readpipe)))
     {
        PL_lex_op = (OP*)newUNOP(OP_ENTERSUB, OPf_STACKED,
@@ -3906,10 +3907,11 @@ Perl_yylex(pTHX)
 #endif
 #ifdef PERL_MAD
        PL_realtokenstart = -1;
-       s = SKIPSPACE0(s);
-#else
-       s++;
+       if (!PL_thiswhite)
+           PL_thiswhite = newSVpvs("");
+       sv_catpvn(PL_thiswhite, s, 1);
 #endif
+       s++;
        goto retry;
     case '#':
     case '\n':
@@ -5166,7 +5168,7 @@ Perl_yylex(pTHX)
                }
                if (!ogv &&
                    (gvp = (GV**)hv_fetch(PL_globalstash,PL_tokenbuf,len,FALSE)) &&
-                   (gv = *gvp) != (GV*)&PL_sv_undef &&
+                   (gv = *gvp) && isGV_with_GP(gv) &&
                    GvCVu(gv) && GvIMPORTED_CV(gv))
                {
                    ogv = gv;
@@ -6416,7 +6418,7 @@ Perl_yylex(pTHX)
 
        case KEY_readpipe:
            set_csh();
-           UNI(OP_BACKTICK);
+           UNIDOR(OP_BACKTICK);
 
        case KEY_rewinddir:
            UNI(OP_REWINDDIR);
@@ -6987,7 +6989,11 @@ S_pending_ident(pTHX)
     if (pit == '@' && PL_lex_state != LEX_NORMAL && !PL_lex_brackets) {
         GV *gv = gv_fetchpv(PL_tokenbuf+1, 0, SVt_PVAV);
         if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv)))
-             && ckWARN(WARN_AMBIGUOUS))
+               && ckWARN(WARN_AMBIGUOUS)
+               /* DO NOT warn for @- and @+ */
+               && !( PL_tokenbuf[2] == '\0' &&
+                   ( PL_tokenbuf[1] == '-' || PL_tokenbuf[1] == '+' ))
+          )
         {
             /* Downgraded from fatal to warning 20000522 mjd */
             Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
@@ -10438,7 +10444,11 @@ S_checkcomma(pTHX_ const char *s, const char *name, const char *what)
            }
            while (isSPACE(*w))
                ++w;
-           if (!*w || !strchr(";|})]oaiuw!=", *w))     /* an advisory hack only... */
+           /* the list of chars below is for end of statements or
+            * block / parens, boolean operators (&&, ||, //) and branch
+            * constructs (or, and, if, until, unless, while, err, for).
+            * Not a very solid hack... */
+           if (!*w || !strchr(";&/|})]oaiuwef!=", *w))
                Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
                            "%s (...) interpreted as function",name);
        }
@@ -11378,7 +11388,7 @@ S_scan_inputsymbol(pTHX_ char *start)
                && GvCVu(gv_readline) && GvIMPORTED_CV(gv_readline))
                ||
                ((gvp = (GV**)hv_fetchs(PL_globalstash, "readline", FALSE))
-               && (gv_readline = *gvp) != (GV*)&PL_sv_undef
+                && (gv_readline = *gvp) && isGV_with_GP(gv_readline)
                && GvCVu(gv_readline) && GvIMPORTED_CV(gv_readline)))
            readline_overriden = TRUE;