summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-02-18 11:14:43 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-02-18 11:14:43 +0000
commitedd7382e985077dac6582d6406b3a16fa5fff0e9 (patch)
tree430be6021dfb905f113683834682185d7c38938b
parentc4e79b56de248a67c4a29293bd16f39465dde417 (diff)
downloadperl-edd7382e985077dac6582d6406b3a16fa5fff0e9.tar.gz
Add tests for the C<my $x if foo> deprecation, and change the
warning text p4raw-id: //depot/perl@22332
-rw-r--r--op.c2
-rw-r--r--pod/perldiag.pod2
-rw-r--r--t/lib/warnings/op57
3 files changed, 59 insertions, 2 deletions
diff --git a/op.c b/op.c
index d6d9aee6ff..97dd95514e 100644
--- a/op.c
+++ b/op.c
@@ -6003,7 +6003,7 @@ Perl_ck_state(pTHX_ OP *o)
&& (ckWARN(WARN_DEPRECATED)))
{
Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
- "Use of my in conditional deprecated");
+ "Deprecated use of my() in conditional");
}
return o;
}
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 19bfa5efa4..a2c7348b12 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -4282,7 +4282,7 @@ old way has bad side effects.
it already went past any symlink you are presumably trying to look for.
The operation returned C<undef>. Use a filename instead.
-=item Use of my in conditional deprecated
+=item Deprecated use of my() in conditional
(D deprecated) You used a C<my> declaration within a conditional
expression of some sort, such as C<my $x=1 if foo> or C<foo && (my $x = 1)>.
diff --git a/t/lib/warnings/op b/t/lib/warnings/op
index 486a00aa9a..c101ffe79c 100644
--- a/t/lib/warnings/op
+++ b/t/lib/warnings/op
@@ -1050,3 +1050,60 @@ Useless localization of defined or assignment (//=) at - line 45.
Useless localization of substr at - line 48.
Useless localization of match position at - line 49.
Useless localization of vec at - line 50.
+########
+# op.c
+use warnings 'deprecated';
+our $a;
+my $x1 if $a;
+my @x2 if $a;
+my %x3 if $a;
+my ($x4) if $a;
+my ($x5,@x6, %x7) if $a;
+my @x8 if ($a+$a);
+my $x9 = 1+$a if $a;
+my ($x10,@x11) = ($a,$a+$a) if $a;
+my ($x12) = 1 if $a;
+my $y1 unless $a;
+my @y2 unless $a;
+my %y3 unless $a;
+my ($y4) unless $a;
+my ($y5,@y6, %y7) unless $a;
+my @y8 unless ($a+$a);
+$a && my $z1;
+$a && my (%z2);
+$a || my @z3;
+$a || my (%z4);
+$a || my (%z4,$z5);
+$a && (my $z6 = 1);
+$a && (my ($z7,@z8) = (1,2,3));
+
+# these shouldn't warn
+our $x if $a;
+our $x unless $a;
+if ($a) { my $w1 }
+if (my $w2) { $a=1 }
+if ($a && (my $w3 = 1)) {$a = 2}
+
+EXPECT
+Deprecated use of my() in conditional at - line 4.
+Deprecated use of my() in conditional at - line 5.
+Deprecated use of my() in conditional at - line 6.
+Deprecated use of my() in conditional at - line 7.
+Deprecated use of my() in conditional at - line 8.
+Deprecated use of my() in conditional at - line 9.
+Deprecated use of my() in conditional at - line 10.
+Deprecated use of my() in conditional at - line 11.
+Deprecated use of my() in conditional at - line 12.
+Deprecated use of my() in conditional at - line 13.
+Deprecated use of my() in conditional at - line 14.
+Deprecated use of my() in conditional at - line 15.
+Deprecated use of my() in conditional at - line 16.
+Deprecated use of my() in conditional at - line 17.
+Deprecated use of my() in conditional at - line 18.
+Deprecated use of my() in conditional at - line 19.
+Deprecated use of my() in conditional at - line 20.
+Deprecated use of my() in conditional at - line 21.
+Deprecated use of my() in conditional at - line 22.
+Deprecated use of my() in conditional at - line 23.
+Deprecated use of my() in conditional at - line 24.
+Deprecated use of my() in conditional at - line 25.