New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"my" variable in a recursive subroutine leaks to callers scope #5690
Comments
From @thundergnatI have a subroutine that may recurse, that contains a "my" counter See cut down snippet: <perl6> sub process-list (@items, $level = 0) { my $count = 1; # leaks on recursion? multi sub process-item ($item, $level) { ' ' x $level ~ multi sub process-item (@array, $level) { process-list(@array, join "\n", map { process-item($_, $level) }, @items; my @a = 'a', 'b'; </perl6> Output: Got 1) 9 Expected: 1) 9 |
From @LLFournReproduced. Looks like you shouldn't nest subs inside recursive functions sub process-list (@items, $level = 0) { multi sub process-item (@array) { join "\n", map &process-item, @items; my @a = 'a', 'b'; 9 ^ It is never incremented/re-assigned but $level is still +1 after the call On Sat, Sep 24, 2016 at 8:07 AM Steve Schulze <perl6-bugs-followup@perl.org>
|
The RT System itself - Status changed from 'new' to 'open' |
From @jnthnOn Sat Sep 24 01:02:24 2016, lloyd.fourn@gmail.com wrote:
I think it's only multis that suffer the problem. /jnthn |
Migrated from rt.perl.org#129344 (status was 'open')
Searchable as RT129344$
The text was updated successfully, but these errors were encountered: