# New Ticket Created by cygx
# Please include the string: [perl #131548]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=131548 >
Example code:
$ cat bug.p6
for ^7 {
my $x = 1;
1 andthen print "$x "
andthen $x = 2
andthen $x = 3
andthen $x = 4;
}
Output:
$ perl6 bug.p6
1 4 3 3 3 3 3
We apparently create a closure over the wrong value of $x.
$ perl6 --version
This is Rakudo version 2017.05-356-gac8b4714f built on MoarVM version
2017.05-50-g6a372ac4
implementing Perl 6.c.
See also https://irclog.perlgeek.de/perl6/2017-06-09#i_14711768