- Log -----------------------------------------------------------------
commit 75068674a0c83a71b3705f2c6000b34d849b9640
Author: Rafael Garcia-Suarez <r...@consttype.org>
Date: Sun Nov 29 23:30:45 2009 +0100
Make split warn in void context
-----------------------------------------------------------------------
Summary of changes:
op.c | 11 +++++++++++
t/lib/warnings/op | 12 ++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/op.c b/op.c
index d4f6fb3..5cbf917 100644
--- 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 &&
diff --git a/t/lib/warnings/op b/t/lib/warnings/op
index 73f1527..4264615 100644
--- a/t/lib/warnings/op
+++ b/t/lib/warnings/op
@@ -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.
--
Perl5 Master Repository