Skip to content

Commit 3fe67c2

Browse files
committed
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 180c7bb commit 3fe67c2

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
@@ -137,6 +137,38 @@ TODO: {
137137
"undef:de567\nundef:de567", { eval $switches }, "");
138138
}
139139

140+
TODO: {
141+
local $::TODO = 'GH 16364';
142+
143+
my @arr;
144+
my sub foo {
145+
unshift @arr, 7;
146+
$_[0] = 3;
147+
}
148+
149+
@arr = ();
150+
$arr[1] = 1;
151+
foo($arr[0]);
152+
is($arr[1], 3,
153+
'Array element within array range created at correct index from subroutine @_ alias; GH 16364');
154+
155+
@arr = ();
156+
$arr[1] = 1;
157+
foo($arr[5]);
158+
is($arr[6], 3,
159+
'Array element outside array range created at correct index from subroutine @_ alias; GH 16364');
160+
161+
@arr = ();
162+
$arr[1] = 1;
163+
foreach (@arr) {
164+
unshift @arr, 7;
165+
$_ = 3;
166+
last;
167+
}
168+
is($arr[1], 3, 'Array element created at correct index from foreach $_ alias; GH 16364');
169+
170+
}
171+
140172
TODO: {
141173
local $::TODO = 'GH 16865';
142174
fresh_perl('\(sort { 0 } 0, 0 .. "a")', { stderr => 'devnull' });

0 commit comments

Comments
 (0)