This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
rpeep: maintain chain when handling for(reverse..)
authorDavid Mitchell <davem@iabyn.com>
Wed, 9 Dec 2015 14:27:18 +0000 (14:27 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 9 Dec 2015 14:29:47 +0000 (14:29 +0000)
There's code in rpeep() that eliminates the reverse op from
for (reverse ....) {} and just flags the enteriter as needing to reverse
its args.

This code didn't leave oldoldop -> oldop -> o as a consistent chain of
adjacent op_next ops.

op.c

diff --git a/op.c b/op.c
index 07a9121..30595b7 100644 (file)
--- a/op.c
+++ b/op.c
@@ -14154,6 +14154,11 @@ Perl_rpeep(pTHX_ OP *o)
            op_null(o);
            enter->op_private |= OPpITER_REVERSED;
            iter->op_private |= OPpITER_REVERSED;
+
+            oldoldop = NULL;
+            oldop    = ourlast;
+            o        = oldop->op_next;
+            goto redo;
            
            break;
        }