This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t warn for open local *FH
authorFather Chrysostomos <sprout@cpan.org>
Thu, 8 Dec 2011 21:09:39 +0000 (13:09 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 8 Dec 2011 21:51:19 +0000 (13:51 -0800)
There is this ancient ‘Precedence problem’ warning that warns for open
followed by a bareword and then an operator that would have made open
into a unary-precedence operator in Perl 4.  It was not taking into
account that the bareword might be a Perl keyword.  In that case it
shouldn’t be warning.

t/lib/warnings/toke
toke.c

index 95612eb..25d53a0 100644 (file)
@@ -644,6 +644,7 @@ Ambiguous use of -fred resolved as -&fred() at - line 11.
 ########
 # toke.c
 open FOO || time;
+open local *FOO; # should be ok
 EXPECT
 Precedence problem: open FOO should be open(FOO) at - line 2.
 ########
diff --git a/toke.c b/toke.c
index e5da941..2c29c58 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -7672,6 +7672,7 @@ Perl_yylex(pTHX)
                if ( *t && strchr("|&*+-=!?:.", *t) && ckWARN_d(WARN_PRECEDENCE)
                    /* [perl #16184] */
                    && !(t[0] == '=' && t[1] == '>')
+                   && !keyword(s, d-s, 0)
                ) {
                    int parms_len = (int)(d-s);
                    Perl_warner(aTHX_ packWARN(WARN_PRECEDENCE),