# Why these are different for MacOS? Does it matter?
my $cop_seq_mnum = $^O eq 'MacOS' ? 12 : 11;
-my $seq_mnum = $^O eq 'MacOS' ? 100 : 84;
+my $seq_mnum = $^O eq 'MacOS' ? 102 : 86;
$cop_seq_base = svref_2object(eval 'sub{0;}')->START->cop_seq + $cop_seq_mnum;
$seq_base = svref_2object(eval 'sub{}')->START->seq + $seq_mnum;
{
int needblockscope = PL_hints & HINT_BLOCK_SCOPE;
line_t copline = PL_copline;
- /* there should be a nextstate in every block */
- OP* retval = seq ? scalarseq(seq) : newSTATEOP(0, Nullch, seq);
- PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */
+ OP* retval = scalarseq(seq);
+ if (!seq) {
+ /* scalarseq() gave us an OP_STUB */
+ retval->op_flags |= OPf_PARENS;
+ /* there should be a nextstate in every block */
+ retval = newSTATEOP(0, Nullch, retval);
+ PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */
+ }
LEAVE_SCOPE(floor);
PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
if (needblockscope)
PL_curpm = newpm;
LEAVE;
LEAVESUB(sv);
- DIE(aTHX_ "Can't return a %s from lvalue subroutine",
- SvREADONLY(TOPs) ? "readonly value" : "temporary");
+ DIE(aTHX_ "Can't return %s from lvalue subroutine",
+ SvREADONLY(TOPs) ? (TOPs == &PL_sv_undef) ? "undef"
+ : "a readonly value" : "a temporary");
}
else { /* Can be a localized value
* subject to deletion. */
use Config;
-print "1..173\n";
+print "1..174\n";
my $test = 1;
sub test (&) {
}->();
test {1};
+# [perl #17605] found that an empty block called in scalar context
+# can lead to stack corruption
+{
+ my $x = "foooobar";
+ $x =~ s/o//eg;
+ test { $x eq 'fbar' }
+}
EOE
print "# '$_'.\nnot "
- unless /Empty array returned from lvalue subroutine in scalar context/;
+ unless /Can't return undef from lvalue subroutine/;
print "ok 31\n";
sub lv10 : lvalue {}
EOE
print "# '$_'.\nnot "
- unless /Can\'t return a readonly value from lvalue subroutine/;
+ unless /Can't return undef from lvalue subroutine/;
print "ok 33\n";
$_ = undef;