From: Rafael Garcia-Suarez Date: Mon, 26 Mar 2007 14:21:39 +0000 (+0000) Subject: Make the warning "interpreted as function" a bit less annoying, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b14399855b4df2051e11477e4e745c80bb82b015;p=p5sagit%2Fp5-mst-13.2.git Make the warning "interpreted as function" a bit less annoying, and test it properly p4raw-id: //depot/perl@30761 --- diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index af27047..f4842a7 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -279,9 +279,14 @@ Possible attempt to put comments in qw() list at - line 3. ######## # toke.c use warnings 'syntax' ; -print ("") +print (""); +print ("") and $x = 1; +print ("") or die; +print ("") // die; +print (1+2) * 3 if 0; # only this one should warn +print (1+2) if 0; EXPECT -print (...) interpreted as function at - line 3. +print (...) interpreted as function at - line 7. ######## # toke.c no warnings 'syntax' ; @@ -291,9 +296,10 @@ EXPECT ######## # toke.c use warnings 'syntax' ; -printf ("") +printf (""); +printf ("") . ''; EXPECT -printf (...) interpreted as function at - line 3. +printf (...) interpreted as function at - line 4. ######## # toke.c no warnings 'syntax' ; @@ -303,9 +309,10 @@ EXPECT ######## # toke.c use warnings 'syntax' ; -sort ("") +sort (""); +sort ("") . ''; EXPECT -sort (...) interpreted as function at - line 3. +sort (...) interpreted as function at - line 4. ######## # toke.c no warnings 'syntax' ; diff --git a/toke.c b/toke.c index 935a32a..96b33cb 100644 --- a/toke.c +++ b/toke.c @@ -10444,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); }