mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
[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:
parent
bbde7ba366
commit
2bf54cc6ef
2
pp_ctl.c
2
pp_ctl.c
@ -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;
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ sub failed {
|
||||
return;
|
||||
}
|
||||
|
||||
sub is {
|
||||
sub is($$$) {
|
||||
my ($got, $expect, $name) = @_;
|
||||
$test = $test + 1;
|
||||
if (defined $expect) {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user