This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop recursion from losing lex fh names
authorFather Chrysostomos <sprout@cpan.org>
Tue, 20 Aug 2013 00:39:45 +0000 (17:39 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 20 Aug 2013 19:50:00 +0000 (12:50 -0700)
commit25451ceff7e8f05c501ecc72a1b3536005f391f7
tree0aacb594ff7bd6454c9dbc8b844969cfb84fdf0b
parent7e8c6c4cac89df95535a8354d57396d3144876b8
Stop recursion from losing lex fh names

sub r {
    r($_[0]-1) if $_[0];
    open my $fh, "/dev/null";
    print "$_[0] $$fh\n"
}
r(5);
__END__

Output:
0 *main::
1 *main::
2 *main::
3 *main::
4 *main::
5 *main::$fh

The largest number represents the outermost call.

The handle name was being allocated as a target (a scratch variable
used by various operators to return values).  Targets are not shared
between recursion levels.

This commit tells pad_alloc to treat it like a constant, so it
is shared.
op.c
t/op/gv.t