diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-05 08:48:35 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-05 08:48:35 -0800 |
commit | a46b39a853149ac3ddcaad16f3c7be0b86d520d0 (patch) | |
tree | 2e348384b86880b5278f7bebfec766ac1a3295e9 /t | |
parent | bade7fbcf63fdefa0b4fd8a0321087860e413483 (diff) | |
download | perl-a46b39a853149ac3ddcaad16f3c7be0b86d520d0.tar.gz |
[perl #90030] sort with no arguments
This eliminates the error ‘sort is now a reserved word’, which was
added for the sake of code that does close(sort) at about the time
that sort became a keyword.
As Tom Christiansen pointed out, it has been long enough.
This error only occurred with ) or ; after the keyword. In other
cases with no arguments, like {sort} and (sort,0), it was treated as
an empty list.
So this commit makes it follow that.
Since the tests triggered it, this commit also fixes a crash caused by
commit 540dd770, which, when seeing whether it can optimise something
like ‘@a = sort @a’, assumes that there is something after the sort,
and crashes when there isn’t, as in {@a = sort}.
Diffstat (limited to 't')
-rw-r--r-- | t/op/sort.t | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/t/op/sort.t b/t/op/sort.t index 2ab0cf5305..df1113b5ce 100644 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -6,7 +6,7 @@ BEGIN { require 'test.pl'; } use warnings; -plan( tests => 165 ); +plan( tests => 171 ); # these shouldn't hang { @@ -949,3 +949,14 @@ is join("", sort hopefullynonexistent split//, '04381091'), '98431100', my $stubref = \&givemeastub; is join("", sort $stubref split//, '04381091'), '98431100', 'AUTOLOAD with stubref'; + +# [perl #90030] sort without arguments +#eval '@x = (sort); 1'; +is $@, '', '(sort) does not die'; +is @x, 0, '(sort) returns empty list'; +#eval '@x = sort; 1'; +is $@, '', 'sort; does not die'; +is @x, 0, 'sort; returns empty list'; +eval '{@x = sort} 1'; +is $@, '', '{sort} does not die'; +is @x, 0, '{sort} returns empty list'; |