From: Rafael Garcia-Suarez Date: Sun, 29 Nov 2009 22:30:45 +0000 (+0100) Subject: Make split warn in void context X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=75068674a0c83a71b3705f2c6000b34d849b9640;p=p5sagit%2Fp5-mst-13.2.git Make split warn in void context --- 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.