This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make split warn in void context
authorRafael Garcia-Suarez <rgs@consttype.org>
Sun, 29 Nov 2009 22:30:45 +0000 (23:30 +0100)
committerRafael Garcia-Suarez <rgs@consttype.org>
Sun, 29 Nov 2009 22:30:45 +0000 (23:30 +0100)
op.c
t/lib/warnings/op

diff --git a/op.c b/op.c
index d4f6fb3..5cbf917 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1086,6 +1086,17 @@ Perl_scalarvoid(pTHX_ OP *o)
            useless = OP_DESC(o);
        break;
 
+    case OP_SPLIT:
+       kid = cLISTOPo->op_first;
+       if (kid && kid->op_type == OP_PUSHRE
+#ifdef USE_ITHREADS
+               && !((PMOP*)kid)->op_pmreplrootu.op_pmtargetoff)
+#else
+               && !((PMOP*)kid)->op_pmreplrootu.op_pmtargetgv)
+#endif
+           useless = OP_DESC(o);
+       break;
+
     case OP_NOT:
        kid = cUNOPo->op_first;
        if (kid->op_type != OP_MATCH && kid->op_type != OP_SUBST &&
index 73f1527..4264615 100644 (file)
@@ -1057,3 +1057,15 @@ $[ = 3;
 EXPECT
 Use of assignment to $[ is deprecated at - line 2.
 Use of assignment to $[ is deprecated at - line 4.
+########
+# op.c
+use warnings 'void';
+@x = split /y/, "z";
+$x = split /y/, "z";
+     split /y/, "z";
+no warnings 'void';
+@x = split /y/, "z";
+$x = split /y/, "z";
+     split /y/, "z";
+EXPECT
+Useless use of split in void context at - line 5.