This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix [perl #74118] $[ assignment not noisy enough
authorZefram <zefram@fysh.org>
Sat, 1 May 2010 17:47:58 +0000 (18:47 +0100)
committerRafael Garcia-Suarez <rgs@consttype.org>
Mon, 16 Aug 2010 12:48:23 +0000 (14:48 +0200)
Warn about list assignment to $[, as in "($[)=1", in addition to scalar
assignment such as "$[=1".

op.c
t/lib/warnings/op

diff --git a/op.c b/op.c
index 5a0962b..48b2a36 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4275,6 +4275,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right)
        if (PL_eval_start)
            PL_eval_start = 0;
        else if (left->op_type == OP_CONST) {
+           deprecate("assignment to $[");
            /* FIXME for MAD */
            /* Result of assignment is always 1 (or we'd be dead already) */
            return newSVOP(OP_CONST, 0, newSViv(1));
index 4264615..962ff58 100644 (file)
@@ -1050,13 +1050,18 @@ Deprecated use of my() in false conditional at - line 8.
 ########
 # op.c
 $[ = 1;
+($[) = 1;
 use warnings 'deprecated';
 $[ = 2;
+($[) = 2;
 no warnings 'deprecated';
 $[ = 3;
+($[) = 3;
 EXPECT
 Use of assignment to $[ is deprecated at - line 2.
-Use of assignment to $[ is deprecated at - line 4.
+Use of assignment to $[ is deprecated at - line 3.
+Use of assignment to $[ is deprecated at - line 5.
+Use of assignment to $[ is deprecated at - line 6.
 ########
 # op.c
 use warnings 'void';