In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1eb3f3ad74c5c8cb35d027485b9938eb0a64db40?hp=2c4c1ff210d35acd69f4b57f0453bc23e7b1c98a>
- Log ----------------------------------------------------------------- commit 1eb3f3ad74c5c8cb35d027485b9938eb0a64db40 Author: James Mastros <[email protected]> Date: Thu Jul 8 22:07:48 2010 +0100 Make the success and failure messages of t/porting/diag.t more clear, and add comments M t/porting/diag.t commit bdac9d717d6341cb8bde12c7706da7e9793fca3a Author: James Mastros <[email protected]> Date: Thu Jul 8 21:41:27 2010 +0100 Remove "at - line 3" from the end of a perldiag entry. M pod/perldiag.pod commit 397d0f13088c8f2fc07173a360ea1bb9227301e5 Author: James Mastros <[email protected]> Date: Wed Jun 2 18:32:19 2010 +0100 Document "Ambiguous use of -%s resolved as -&%s()" M pod/perldiag.pod M t/porting/diag.t commit 4da603770916eeea54d6ad0bca34bd83bd01dc35 Author: James Mastros <[email protected]> Date: Wed Jun 2 18:27:48 2010 +0100 Document "Ambiguous use of %c{%s%s} resolved to %c%s%s" M pod/perldiag.pod M t/porting/diag.t commit 1ef43bca16a834dad67a76e73eb6ed31d2a46cb1 Author: James Mastros <[email protected]> Date: Wed Jun 2 17:44:45 2010 +0100 Document "Ambiguous use of %c{%s} resolved to %c%s" M pod/perldiag.pod M t/porting/diag.t commit d8225693adef7017da64423203537ac5d68cfff8 Author: James Mastros <[email protected]> Date: Wed Jun 2 17:35:22 2010 +0100 Document "Ambiguous use of %c resolved as operator %c" M pod/perldiag.pod M t/porting/diag.t commit b0227916d216511cb22e759e8a083bf97a928fb5 Author: James Mastros <[email protected]> Date: Wed Jun 2 17:22:59 2010 +0100 Stick a comment in t/porting/diag.t begging people not to abuse the ignore list M t/porting/diag.t commit de2b151d9e0876a9d49b0e149d8417cbf593de16 Author: James Mastros <[email protected]> Date: Wed Jun 2 17:22:36 2010 +0100 Normalize formatting of "Ambiguous call resolved as CORE::%s(), qualify as such or use &" in toke.c, so t/porting/diag.t can find it. M t/porting/diag.t M toke.c ----------------------------------------------------------------------- Summary of changes: pod/perldiag.pod | 34 ++++++++++++++++++++++++++++++++++ t/porting/diag.t | 31 ++++++++++++++++++++++--------- toke.c | 5 +++-- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 9166457..241ad01 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -89,6 +89,40 @@ C<tr/a-y//>, which was probably not what you would have expected.) you thought. Normally it's pretty easy to disambiguate it by supplying a missing quote, operator, parenthesis pair or declaration. +=item Ambiguous use of %c resolved as operator %c + +(W ambiguous) C<%>, C<&>, and C<*> are both infix operators (modulus, +bitwise and, and multpication), and you said something like C<*foo * +foo> that might be interpreted as either of them. We assumed you +meant the infix operator, but please try to make it more clear -- in +the example given, you might write C<*foo * foo()> if you really meant +to multiply a glob by the result of calling a function. + +=item Ambiguous use of %c{%s} resolved to %c%s + +(W ambiguous) You wrote something like C<@{foo}>, which might be +asking for the variable C<@foo>, or it might be calling a function +named foo, and dereferencing it as an array reference. If you wanted +the varable, you can just write C<@foo>. If you wanted to call the +function, write C<@{foo()}> ... or you could just not have a variable +and a function with the same name, and save yourself a lot of trouble. + +=item Ambiguous use of %c{%s%s} resolved to %c%s%s + +(W ambiguous) You wrote something like C<${foo[2]}>, which might be +looking for element number 2 of the array named C<@foo>, in which case +please write C<$foo[2]>, or you might have meant to pass an anonymous +arrayref to the function named foo, then do a scalar deref on the +value it returns. If you meant that, write C<${foo([2])}>. + +=item Ambiguous use of -%s resolved as -&%s() + +(W ambiguous) You wrote something like C<-foo>, which might be the +string C<"-foo"> (outside of C<use strict 'subs'>), or a call to the +function C<foo>, negated. If you meant the string, just write +C<"-foo">, and please use strict. If you meant the function call, +write C<-foo()>. + =item '|' and '<' may not both be specified on command line (F) An error peculiar to VMS. Perl does its own command line diff --git a/t/porting/diag.t b/t/porting/diag.t index 7c05172..eeb167d 100644 --- a/t/porting/diag.t +++ b/t/porting/diag.t @@ -8,6 +8,12 @@ plan('no_plan'); $|=1; +# --make-exceptions-list outputs the list of strings that don't have +# perldiag.pod entries to STDERR without TAP formatting, so they can +# easily be put in the __DATA__ section of this file. This was done +# initially so as to not create new test failures upon the initial +# creation of this test file. You probably shouldn't do it again. +# Just add the documentation instead. my $make_exceptions_list = ($ARGV[0]||'') eq '--make-exceptions-list'; chdir '..' or die "Can't chdir ..: $!"; @@ -197,22 +203,31 @@ sub check_file { TODO: { no warnings 'once'; local $::TODO = 'in DATA'; - fail("Presence of '$name' from $codefn line $."); + # There is no listing, but it is in the list of exceptions. TODO FAIL. + fail("No listing in pod/perldiag.pod for '$name' from $codefn line $ (but it wasn't documented in 5.10 either, so we're letting it slide)."); } } else { - ok("Presence of '$name' from $codefn line $."); + # We found an actual valid entry in perldiag.pod for this error. + ok("Found listing in pod/perldiag.pod for '$name' from $codefn line $."); } # Later, should start checking that the severity is correct, too. } elsif ($name =~ m/^panic: /) { # Just too many panic:s, they are hard to diagnose, and there # is a generic "panic: %s" entry. Leave these for another # pass. - ok("Presence of '$name' from $codefn line $., covered by panic: %s entry"); + ok("Skipping lack of explicit perldiag entry for '$name' from $codefn line $., covered by panic: %s entry"); } else { if ($make_exceptions_list) { + # We're making an updated version of the exception list, to + # stick in the __DATA__ section. I honestly can't think of + # a situation where this is the right thing to do, but I'm + # leaving it here, just in case one of my descendents thinks + # it's a good idea. print STDERR "$name\n"; } else { - fail("Presence of '$name' from $codefn line $."); + # No listing found, and no excuse either. + # Find the correct place in perldiag.pod, and add a stanza beginning =item $name. + fail("No listing in pod/perldiag.pod for '$name' from $codefn line $."); } } @@ -222,12 +237,10 @@ sub check_file { } # Lists all missing things as of the inaguration of this script, so we # don't have to go from "meh" to perfect all at once. +# +# PLEASE DO NOT ADD TO THIS LIST. Instead, write an entry in +# pod/perldiag.pod for your new (warning|error). __DATA__ -Ambiguous call resolved as CORE::%s(), %s -Ambiguous use of %c resolved as operator %c -Ambiguous use of %c{%s} resolved to %c%s -Ambiguous use of %c{%s%s} resolved to %c%s%s -Ambiguous use of -%s resolved as -&%s() Argument "%s" isn't numeric Argument "%s" isn't numeric in %s Attempt to clear deleted array diff --git a/toke.c b/toke.c index 75fb327..1e7cdb5 100644 --- a/toke.c +++ b/toke.c @@ -6204,8 +6204,9 @@ Perl_yylex(pTHX) gvp = 0; if (hgv && tmp != KEY_x && tmp != KEY_CORE) /* never ambiguous */ Perl_ck_warner(aTHX_ packWARN(WARN_AMBIGUOUS), - "Ambiguous call resolved as CORE::%s(), %s", - GvENAME(hgv), "qualify as such or use &"); + "Ambiguous call resolved as CORE::%s(), " + "qualify as such or use &", + GvENAME(hgv)); } } -- Perl5 Master Repository
