Skip to content

Commit

Permalink
Merge f3d7851 into 2723cea
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Jun 15, 2021
2 parents 2723cea + f3d7851 commit ef69381
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions op.c
Expand Up @@ -2621,8 +2621,13 @@ S_scalarseq(pTHX_ OP *o)
if (type == OP_LINESEQ || type == OP_SCOPE ||
type == OP_LEAVE || type == OP_LEAVETRY)
{
OP *kid, *sib;
for (kid = cLISTOPo->op_first; kid; kid = sib) {
OP *kid = cLISTOPo->op_first, *sib;
if(type == OP_LEAVE) {
/* Don't put the OP_ENTER in void context */
assert(kid->op_type == OP_ENTER);
kid = OpSIBLING(kid);
}
for (; kid; kid = sib) {
if ((sib = OpSIBLING(kid))
&& ( OpHAS_SIBLING(sib) || sib->op_type != OP_NULL
|| ( sib->op_targ != OP_NEXTSTATE
Expand Down
16 changes: 16 additions & 0 deletions t/op/try.t
Expand Up @@ -232,6 +232,14 @@ no warnings 'experimental::try';
catch ($e) { 4, 5, 6 }
};
ok(eq_array(\@list, [1, 2, 3]), 'do { try } in list context');

# Regression test related to
# https://github.com/Perl/perl5/issues/18855
$scalar = do {
try { my $x = 123; 456 }
catch ($e) { 789 }
};
is($scalar, 456, 'do { try } with multiple statements');
}

# catch as final expression yields correct value
Expand All @@ -247,6 +255,14 @@ no warnings 'experimental::try';
catch ($e) { 4, 5, 6 }
};
ok(eq_array(\@list, [4, 5, 6]), 'do { try/catch } in list context');

# Regression test
# https://github.com/Perl/perl5/issues/18855
$scalar = do {
try { die "Oops" }
catch ($e) { my $x = 123; "result" }
};
is($scalar, "result", 'do { try/catch } with multiple statements');
}

# try{} blocks should be invisible to caller()
Expand Down

0 comments on commit ef69381

Please sign in to comment.