Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion t/op/array.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BEGIN {
set_up_inc('.', '../lib');
}

plan (195);
plan (197);

#
# @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
Expand Down Expand Up @@ -707,3 +707,15 @@ fresh_perl_is('my @x;$x[0] = 1;shift @x;$x[22] = 1;$x[25] = 1;','',
{}, 'unshifting and growing an array initializes trailing elements');

"We're included by lib/Tie/Array/std.t so we need to return something true";

# GH #23447 - ensure that future optimizations don't break behaviour
{
my @x = "a" .. "d";
sub f {}
my $y = @x[2, 3, f()];
is $y, 'd', 'Trailing empty list return in array slice in scalar context';

my @i;
$y = @x[2, 3, @i];
is $y, 'd', 'Empty array final element in array slice in scalar context';
}
13 changes: 12 additions & 1 deletion t/op/list.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BEGIN {
set_up_inc(qw(. ../lib));
}

plan( tests => 73 );
plan( tests => 75 );

@foo = (1, 2, 3, 4);
cmp_ok($foo[0], '==', 1, 'first elem');
Expand Down Expand Up @@ -275,3 +275,14 @@ EOS
my $e = "1"; $e = "(1,$e)" for 1..100_000; $e = "() = $e"; eval $e;
is $@, "", "SEGV in Perl_list";
}

# GH #23447 - ensure that future optimizations don't break behaviour
{
sub f {}
my $y = ("a" .. "d")[2, 3, f()];
is $y, 'd', 'Trailing empty list return in list slice in scalar context';

my @i;
$y = ("a" .. "d")[2, 3, @i];
is $y, 'd', 'Empty array final element in list slice in scalar context';
}
Loading