diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-04 20:09:29 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-09-04 20:10:19 -0700 |
commit | 7950e9cf39c803dbea774d03b90552b92052b83d (patch) | |
tree | 8a1e40fe56fdf0ff2fa881386eb3b8d7b5dfb70d | |
parent | ca81d15134dd9dc7c213a6d9bbac15adcbc11b08 (diff) | |
download | perl-7950e9cf39c803dbea774d03b90552b92052b83d.tar.gz |
Remove -foo ambiguity warning
$ ./perl -e 'sub foo{} -foo'
Ambiguous use of -foo resolved as -&foo() at -e line 1.
There is no ambiguity there, since unary minus does not force
its argument to be a bareword; it simply exempts barewords from
strictures.
This warning also makes it harder to use constantly recently added
to POSIX. To avoid that warning, for negative infinity you have to
write ‘- Inf’ or ‘-+Inf’, because the most natural way of writing it,
‘-Inf’, warns.
See <20140901014232.20757.qmail@lists-nntp.develooper.com> and
related messages.
-rw-r--r-- | t/lib/warnings/toke | 24 | ||||
-rw-r--r-- | toke.c | 11 |
2 files changed, 6 insertions, 29 deletions
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 39d3695d59..8c0158a724 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -783,15 +783,14 @@ use warnings "ambiguous"; print for keys %+; # should not warn EXPECT ######## -# toke.c +# toke.c [This does not warn any more.] sub fred {}; -fred ; sub hank : lvalue {$_} --hank; # This should *not* warn [perl #77240] EXPECT -Ambiguous use of -fred resolved as -&fred() at - line 3. ######## -# toke.c +# toke.c [This does not warn any more.] $^W = 0 ; sub fred {} ; -fred ; @@ -803,19 +802,15 @@ sub fred {} ; } -fred ; EXPECT -Ambiguous use of -fred resolved as -&fred() at - line 4. -Ambiguous use of -fred resolved as -&fred() at - line 9. -Ambiguous use of -fred resolved as -&fred() at - line 11. ######## -# toke.c +# toke.c [This does not warn any more.] use utf8; use open qw( :utf8 :std ); sub frèd {}; -frèd ; EXPECT -Ambiguous use of -frèd resolved as -&frèd() at - line 5. ######## -# toke.c +# toke.c [This does not warn any more.] $^W = 0 ; use utf8; use open qw( :utf8 :std ); @@ -829,19 +824,15 @@ sub frèd {} ; } -frèd ; EXPECT -Ambiguous use of -frèd resolved as -&frèd() at - line 6. -Ambiguous use of -frèd resolved as -&frèd() at - line 11. -Ambiguous use of -frèd resolved as -&frèd() at - line 13. ######## -# toke.c +# toke.c [This does not warn any more.] use utf8; use open qw( :utf8 :std ); sub ᒍᒘᒊ {}; -ᒍᒘᒊ ; EXPECT -Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 5. ######## -# toke.c +# toke.c [This does not warn any more.] $^W = 0 ; use utf8; use open qw( :utf8 :std ); @@ -855,9 +846,6 @@ sub ᒍᒘᒊ {} ; } -ᒍᒘᒊ ; EXPECT -Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 6. -Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 11. -Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 13. ######## # toke.c open FOO || time; @@ -6474,10 +6474,6 @@ Perl_yylex(pTHX) just_a_word: { int pkgname = 0; const char lastchar = (PL_bufptr == PL_oldoldbufptr ? 0 : PL_bufptr[-1]); - const char penultchar = - lastchar && PL_bufptr - 2 >= PL_linestart - ? PL_bufptr[-2] - : 0; bool safebw; @@ -6686,13 +6682,6 @@ Perl_yylex(pTHX) if (cv) { OP *gvop; - if (lastchar == '-' && penultchar != '-') { - const STRLEN l = len ? len : strlen(PL_tokenbuf); - Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS), - "Ambiguous use of -%"UTF8f" resolved as -&%"UTF8f"()", - UTF8fARG(UTF, l, PL_tokenbuf), - UTF8fARG(UTF, l, PL_tokenbuf)); - } /* Check for a constant sub */ if ((sv = cv_const_sv_or_av(cv))) { its_constant: |