Skip to content

Commit

Permalink
RT #124207: assert failure in ck_stringify()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iabyn committed Apr 22, 2015
1 parent a911bb2 commit 82269f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions op.c
Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions t/comp/parser.t
Expand Up @@ -8,7 +8,7 @@ BEGIN {
chdir 't' if -d 't';
}

print "1..172\n";
print "1..173\n";

sub failed {
my ($got, $expected, $name) = @_;
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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.

0 comments on commit 82269f5

Please sign in to comment.