diff options
author | David Mitchell <davem@iabyn.com> | 2015-04-22 16:26:40 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-04-22 16:26:40 +0100 |
commit | 82269f56dcc21a3e0ef8c48158a731daf5ceda25 (patch) | |
tree | d15a6a8403410ab8ff8a3ef27acb43e935f107a2 | |
parent | a911bb254071ab7112c309e8245494c182ad9fe2 (diff) | |
download | perl-82269f56dcc21a3e0ef8c48158a731daf5ceda25.tar.gz |
RT #124207: assert failure in ck_stringify()
v5.21.4-416-g73f4c4f converted (among other things) stringify(join(...))
into just join(...). It asserted that the stringify didn't have any extra
children, which it won't normally do, since in something like "@a-" the
elements of the stringify get bundled up into a single tree of concats
etc, and stringify just sees a single top-level join or concat or
whatever. However during error recovery weird stuff can get left on the
stack.
So rather than asserting no more kids, skip the optimisation if there are
more kids.
-rw-r--r-- | op.c | 8 | ||||
-rw-r--r-- | t/comp/parser.t | 11 |
2 files changed, 13 insertions, 6 deletions
@@ -11118,11 +11118,11 @@ Perl_ck_stringify(pTHX_ OP *o) { OP * const kid = OpSIBLING(cUNOPo->op_first); PERL_ARGS_ASSERT_CK_STRINGIFY; - if (kid->op_type == OP_JOIN || kid->op_type == OP_QUOTEMETA - || kid->op_type == OP_LC || kid->op_type == OP_LCFIRST - || kid->op_type == OP_UC || kid->op_type == OP_UCFIRST) + if (( kid->op_type == OP_JOIN || kid->op_type == OP_QUOTEMETA + || kid->op_type == OP_LC || kid->op_type == OP_LCFIRST + || kid->op_type == OP_UC || kid->op_type == OP_UCFIRST) + && !OpHAS_SIBLING(kid)) /* syntax errs can leave extra children */ { - assert(!OpHAS_SIBLING(kid)); op_sibling_splice(o, cUNOPo->op_first, -1, NULL); op_free(o); return kid; diff --git a/t/comp/parser.t b/t/comp/parser.t index a4ae0524a9..50f601cf45 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -8,7 +8,7 @@ BEGIN { chdir 't' if -d 't'; } -print "1..172\n"; +print "1..173\n"; sub failed { my ($got, $expected, $name) = @_; @@ -540,6 +540,13 @@ eval "grep+grep"; eval 'my $_; m// ~~ 0'; } +# RT #124207 syntax error during stringify can leave stringify op +# with multiple children and assertion failures + +eval 'qq{@{0]}${}},{})'; +is(1, 1, "RT #124207"); + + # Add new tests HERE (above this line) # bug #74022: Loop on characters in \p{OtherIDContinue} @@ -688,4 +695,4 @@ check_line(642, 'line number after ${expr} surrounding heredoc body'); __END__ -# Don't add new tests HERE. See note above +# Don't add new tests HERE. See "Add new tests HERE" above. |