This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
assertion failure in ... or ((0) x 0))
authorDavid Mitchell <davem@iabyn.com>
Mon, 5 Dec 2016 14:54:44 +0000 (14:54 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Dec 2016 14:56:43 +0000 (14:56 +0000)
[perl #130247] Perl_rpeep(OP *): Assertion `oldop' failed

the 'x 0' optimising code in rpeep didn't expect the repeat expression
to occur on the op_other side of an op_next chain.

op.c
t/op/repeat.t

diff --git a/op.c b/op.c
index f8df8b4..722ee35 100644 (file)
--- a/op.c
+++ b/op.c
@@ -13825,10 +13825,10 @@ Perl_rpeep(pTHX_ OP *o)
                  && kid->op_next->op_type == OP_REPEAT
                  && kid->op_next->op_private & OPpREPEAT_DOLIST
                  && (kid->op_next->op_flags & OPf_WANT) == OPf_WANT_LIST
-                 && SvIOK(kSVOP_sv) && SvIVX(kSVOP_sv) == 0)
+                 && SvIOK(kSVOP_sv) && SvIVX(kSVOP_sv) == 0
+                 && oldop)
                 {
                     o = kid->op_next; /* repeat */
-                    assert(oldop);
                     oldop->op_next = o;
                     op_free(cBINOPo->op_first);
                     op_free(cBINOPo->op_last );
index d21bdb3..9789166 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     set_up_inc( '../lib' );
 }
 
-plan(tests => 48);
+plan(tests => 49);
 
 # compile time
 
@@ -183,3 +183,12 @@ fresh_perl_like(
   {  },
  '(1) x ~1',
 );
+
+# [perl #130247] Perl_rpeep(OP *): Assertion `oldop' failed
+# 
+# the 'x 0' optimising code in rpeep didn't expect the repeat expression
+# to occur on the op_other side of an op_next chain.
+# This used to give an assertion failure
+
+eval q{() = (() or ((0) x 0)); 1};
+is($@, "", "RT #130247");