Chris Dolan wrote:
> I stumbled across this issue while descending into a recursive Match
> structure. Consider the following reentrant subroutine:
>
> sub f($n) {
> for 0..$n -> $i {
> say "$i of 0..$n";
> if ($i == 4) {
> f(0);
> }
> }
> };
> f(6);
You have just experienced this bug:
http://rt.perl.org/rt3/Ticket/Display.html?id=58392
"Recursion and for loops interact badly in Rakudo".
Patrick is working on it.
> Am I supposed to making the sub argument lexical?
> sub f(my $n) { ... }
No, your program is fine, and pugs runs it as expected.
Cheers,
Moritz
--
Moritz Lenz
http://perlgeek.de/ | http://perl-6.de/ | http://sudokugarden.de/