This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
optimize away runtime code for our($foo) (also avoid warnings)
[perl5.git] / op.c
diff --git a/op.c b/op.c
index 529506b..29f860c 100644 (file)
--- a/op.c
+++ b/op.c
@@ -6292,7 +6292,15 @@ Perl_peep(pTHX_ register OP *o)
 
        case OP_GV:
            if (o->op_next->op_type == OP_RV2SV) {
-               if (!(o->op_next->op_private & OPpDEREF)) {
+               /* don't execute our($foo) */
+               if (o->op_next->op_private & OPpOUR_INTRO) {
+                   null(o->op_next);
+                   o->op_next = o->op_next->op_next;
+                   null(o);
+                   if (oldop && o->op_next)
+                       oldop->op_next = o->op_next;
+               }
+               else if (!(o->op_next->op_private & OPpDEREF)) {
                    null(o->op_next);
                    o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
                    o->op_next = o->op_next->op_next;