This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Reduce false positives for @hsh{$s} and @ary[$s] warnings
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index 6b19646..c48c9b2 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -1201,6 +1201,9 @@ term      :       termbinop
                                    newLISTOP(OP_ASLICE, 0,
                                        list($3),
                                        ref($1, OP_ASLICE)));
+                         if ($$ && $1)
+                             $$->op_private |=
+                                 $1->op_private & OPpSLICEWARNING;
                          TOKEN_GETMAD($2,$$,'[');
                          TOKEN_GETMAD($4,$$,']');
                        }
@@ -1222,6 +1225,9 @@ term      :       termbinop
                                    newLISTOP(OP_HSLICE, 0,
                                        list($3),
                                        ref(oopsHV($1), OP_HSLICE)));
+                         if ($$ && $1)
+                             $$->op_private |=
+                                 $1->op_private & OPpSLICEWARNING;
                            PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'{');
                          TOKEN_GETMAD($4,$$,';');
@@ -1435,6 +1441,7 @@ scalar    :       '$' indirob
 
 ary    :       '@' indirob
                        { $$ = newAVREF($2);
+                         if ($$) $$->op_private |= IVAL($1);
                          TOKEN_GETMAD($1,$$,'@');
                        }
        ;