From: Rafael Garcia-Suarez Date: Tue, 7 Mar 2006 16:49:58 +0000 (+0000) Subject: $[ = 2 should not warn. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e0ae2d3c84912a75f62cfca2c31658c66304493;p=p5sagit%2Fp5-mst-13.2.git $[ = 2 should not warn. p4raw-id: //depot/perl@27402 --- diff --git a/op.c b/op.c index 1331b15..de36ced 100644 --- a/op.c +++ b/op.c @@ -776,6 +776,8 @@ Perl_scalarvoid(pTHX_ OP *o) else { if (ckWARN(WARN_VOID)) { useless = "a constant"; + if (o->op_private & OPpCONST_ARYBASE) + useless = 0; /* don't warn on optimised away booleans, eg * use constant Foo, 5; Foo || print; */ if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT) @@ -1035,7 +1037,7 @@ Perl_mod(pTHX_ OP *o, I32 type) PL_modcount++; return o; case OP_CONST: - if (!(o->op_private & (OPpCONST_ARYBASE))) + if (!(o->op_private & OPpCONST_ARYBASE)) goto nomod; localize = 0; if (PL_eval_start && PL_eval_start->op_type == OP_CONST) { @@ -3466,6 +3468,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) PL_eval_start = 0; else { o = newSVOP(OP_CONST, 0, newSViv(PL_compiling.cop_arybase)); + o->op_private |= OPpCONST_ARYBASE; } } return o; diff --git a/t/lib/warnings/op b/t/lib/warnings/op index 4f00c12..891677f 100644 --- a/t/lib/warnings/op +++ b/t/lib/warnings/op @@ -528,6 +528,7 @@ use warnings 'void' ; 5 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT use constant U => undef; print "boo\n" if U; # test OPpCONST_SHORTCIRCUIT +$[ = 2; # should not warn no warnings 'void' ; "abc"; # OP_CONST 7 ; # OP_CONST