[perl #80630] Make eval"" return empty list for syntax errors

Up till now, eval"" in list context was returning a list containing
undef for syntax errors and an empty list for run-time errors.
This commit is contained in:
Father Chrysostomos 2011-11-19 11:13:24 -08:00
parent bbde7ba366
commit 2bf54cc6ef
3 changed files with 8 additions and 3 deletions

View File

@ -3649,7 +3649,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq, HV *hh)
sv_setpvs(ERRSV, "Compilation error");
}
}
PUSHs(&PL_sv_undef);
if (gimme != G_ARRAY) PUSHs(&PL_sv_undef);
PUTBACK;
return FALSE;
}

View File

@ -24,7 +24,7 @@ sub failed {
return;
}
sub is {
sub is($$$) {
my ($got, $expect, $name) = @_;
$test = $test + 1;
if (defined $expect) {

View File

@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
plan(tests => 121);
plan(tests => 125);
eval 'pass();';
@ -25,6 +25,11 @@ like($@, qr/line 2/);
print eval '$foo = /'; # this tests for a call through fatal()
like($@, qr/Search/);
is scalar(eval '++'), undef, 'eval syntax error in scalar context';
is scalar(eval 'die'), undef, 'eval run-time error in scalar context';
is +()=eval '++', 0, 'eval syntax error in list context';
is +()=eval 'die', 0, 'eval run-time error in list context';
is(eval '"ok 7\n";', "ok 7\n");
$foo = 5;