Skip to content

Instantly share code, notes, and snippets.

@clsn
Created November 10, 2011 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clsn/1354278 to your computer and use it in GitHub Desktop.
Save clsn/1354278 to your computer and use it in GitHub Desktop.
Recursing bug in perl6 rakudo
my $counter=0;
sub recur(Int $x) {
my $h;
$h="h" ~ $counter;
$counter++;
my @k=(1,6);
if ($x>0) {
recur($x-1);
}
for @k {
say $_ ~ " and h is $h";
}
say "h is $h";
}
recur(3);
@clsn
Copy link
Author

clsn commented Nov 10, 2011

Expected output, and received from earlier perl6 (This is Rakudo Perl 6, version 2011.06 built on parrot 3.5.0 RELEASE_3_5_0):

1 and h is h3
6 and h is h3
h is h3
1 and h is h2
6 and h is h2
h is h2
1 and h is h1
6 and h is h1
h is h1
1 and h is h0
6 and h is h0
h is h0

Output received from later rakudo (This is perl6 version 2011.10-98-g1985138 built on parrot 3.9.0 revision RELEASE_3_9_0-51-g65e6ab7):

1 and h is h3
6 and h is h3
h is h3
1 and h is h3
6 and h is h3
h is h2
1 and h is h3
6 and h is h3
h is h1
1 and h is h3
6 and h is h3
h is h0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment