Skip to content

Commit d78f339

Browse files
committed
Test assignment to holes when iterating arrays
Closes RT#126312.
1 parent a469bf2 commit d78f339

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

β€ŽS04-statements/for.t

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use MONKEY-TYPING;
44

55
use Test;
66

7-
plan 107;
7+
plan 111;
88

99
=begin description
1010
@@ -767,4 +767,17 @@ is (for 5 { (sub { "OH HAI" })() }), "OH HAI", 'Anon sub inside for works.';
767767
is $loops, 5, 'Lazy for loop does no more work than required';
768768
}
769769

770+
# RT#126312
771+
{
772+
my Int @a;
773+
@a[5] = 42;
774+
lives-ok { $_ = 6 for @a }, β€˜holes are mutable (for @a)’;
775+
is @a, <6 6 6 6 6 6>, β€˜holes were changed correctly (for @a)’;
776+
777+
my Int @b;
778+
@b[5] = 24;
779+
lives-ok { $_ = 9 for @b[*] }, β€˜holes are mutable (for @a[*])’;
780+
is @b, <9 9 9 9 9 9>, β€˜holes were changed correctly (for @a[*])’;
781+
}
782+
770783
# vim: ft=perl6

0 commit comments

Comments
Β (0)