From: Jarkko Hietaniemi Date: Tue, 3 Apr 2001 15:03:46 +0000 (+0000) Subject: Change the push/unshift warning (#9532) to talk about "no values" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de4864e4e7ced178416488fa2591227064c3222d;p=p5sagit%2Fp5-mst-13.2.git Change the push/unshift warning (#9532) to talk about "no values" instead of "no arguments". p4raw-id: //depot/perl@9534 --- diff --git a/op.c b/op.c index 44a19d3..4f95857 100644 --- a/op.c +++ b/op.c @@ -5682,7 +5682,7 @@ Perl_ck_fun(pTHX_ OP *o) if ((type == OP_PUSH || type == OP_UNSHIFT) && !kid->op_sibling && ckWARN(WARN_MISC)) Perl_warner(aTHX_ WARN_MISC, - "Useless use of %s with no arguments", + "Useless use of %s with no values", PL_op_desc[type]); if (kid->op_type == OP_CONST && diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 16b4ec2..038b93f 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3682,6 +3682,15 @@ L for more on this. (W) You did C without any arguments. That isn't very useful. +=item Useless use of %s with no values + +(W misc) You used the push() or unshift() function with no arguments +apart from the array, like C or C. That won't +usually have any effect on the array, so is completely useless. It's +possible in principle that push(@tied_array) could have some effect +if the array is tied to a class which implements a PUSH method. If so, +you can write it as C to avoid this warning. + =item "use" not allowed in expression (F) The "use" keyword is recognized and executed at compile time, and @@ -3949,15 +3958,6 @@ which means that Perl 5 will try to call the subroutine when the assignment is executed, which is probably not what you want. (If it IS what you want, put an & in front.) -=item Useless use of %s with no arguments - -(W misc) You used the push() or unshift() function with no arguments -apart from the array, like C or C. That won't -usually have any effect on the array, so is completely useless. It's -possible in principle that push(@tied_array) could have some effect -if the array is tied to a class which implements a PUSH method. If so, -you can write it as C to avoid this warning. - =back =cut diff --git a/t/pragma/warn/op b/t/pragma/warn/op index ab2124e..62268fc 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -894,5 +894,5 @@ no warnings 'misc' ; push(@x); unshift(@x); EXPECT -Useless use of push with no arguments at - line 4. -Useless use of unshift with no arguments at - line 5. +Useless use of push with no values at - line 4. +Useless use of unshift with no values at - line 5.