From: Dave Mitchell Date: Sun, 14 Mar 2004 17:01:34 +0000 (+0000) Subject: [perl #27628] strict 'subs' didn't warn on bareword array index X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af5acbb47cec8f9dd3c4a2594507c21a7f1ce63b;p=p5sagit%2Fp5-mst-13.2.git [perl #27628] strict 'subs' didn't warn on bareword array index p4raw-id: //depot/perl@22499 --- diff --git a/op.c b/op.c index b695a63..d9dcd42 100644 --- a/op.c +++ b/op.c @@ -6405,7 +6405,7 @@ Perl_peep(pTHX_ register OP *o) o->op_next : o->op_next->op_next; IV i; if (pop && pop->op_type == OP_CONST && - (PL_op = pop->op_next) && + ((PL_op = pop->op_next)) && pop->op_next->op_type == OP_AELEM && !(pop->op_next->op_private & (OPpLVAL_INTRO|OPpLVAL_DEFER|OPpDEREF|OPpMAYBE_LVSUB)) && @@ -6414,6 +6414,8 @@ Perl_peep(pTHX_ register OP *o) i >= 0) { GV *gv; + if (cSVOPx(pop)->op_private & OPpCONST_STRICT) + no_bareword_allowed(pop); if (o->op_type == OP_GV) op_null(o->op_next); op_null(pop->op_next); diff --git a/t/lib/strict/subs b/t/lib/strict/subs index 4f0e621..20a8afa 100644 --- a/t/lib/strict/subs +++ b/t/lib/strict/subs @@ -380,3 +380,16 @@ qr/(?{my $x=foo})/; EXPECT Bareword "foo" not allowed while "strict subs" in use at (re_eval 1) line 1. Compilation failed in regexp at - line 3. +######## +# [perl #27628] strict 'subs' didn't warn on bareword array index +use strict 'subs'; +my $x=$a[FOO]; +EXPECT +Bareword "FOO" not allowed while "strict subs" in use at - line 3. +Execution of - aborted due to compilation errors. +######## +use strict 'subs'; +my @a;my $x=$a[FOO]; +EXPECT +Bareword "FOO" not allowed while "strict subs" in use at - line 2. +Execution of - aborted due to compilation errors.