Skip to content

Commit 01de43c

Browse files
1-1samkhwilliamson
authored andcommitted
todo tests for GH 16364 (array element lazily created at wrong index)
This commit adds some todo tests for GH 16364 that test the following behavior: * An array element that was previously uninitialized is created at the correct index when assigned from a subroutine's @_ alias which modifies the element's original array. The element is within the array. * The same as the above but the element is outside of the array's range. * An array element that was previously uninitialized is created at the correct index when assigned from a foreach loop's $_ alias which modifies the element's original array.
1 parent ab83fc2 commit 01de43c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

t/run/todo.t

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,38 @@ TODO: {
195195
"undef:de567\nundef:de567", { eval $switches }, "GH 16250");
196196
}
197197

198+
TODO: {
199+
local $::TODO = 'GH 16364';
200+
201+
my @arr;
202+
my sub foo {
203+
unshift @arr, 7;
204+
$_[0] = 3;
205+
}
206+
207+
@arr = ();
208+
$arr[1] = 1;
209+
foo($arr[0]);
210+
is($arr[1], 3,
211+
'Array element within array range created at correct index from subroutine @_ alias; GH 16364');
212+
213+
@arr = ();
214+
$arr[1] = 1;
215+
foo($arr[5]);
216+
is($arr[6], 3,
217+
'Array element outside array range created at correct index from subroutine @_ alias; GH 16364');
218+
219+
@arr = ();
220+
$arr[1] = 1;
221+
foreach (@arr) {
222+
unshift @arr, 7;
223+
$_ = 3;
224+
last;
225+
}
226+
is($arr[1], 3, 'Array element created at correct index from foreach $_ alias; GH 16364');
227+
228+
}
229+
198230
TODO: {
199231
local $::TODO = 'GH 16865';
200232
fresh_perl('\(sort { 0 } 0, 0 .. "a")', { stderr => 'devnull' });

0 commit comments

Comments
 (0)