Bug 846330 - Lexical subroutines make some variables unavailable
Summary: Lexical subroutines make some variables unavailable
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: perl
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Fedora Extras Quality Assurance
URL: https://rt.perl.org/rt3//Public/Bug/D...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-07 13:25 UTC by Petr Pisar
Modified: 2012-09-11 12:01 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-09-11 12:01:25 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Pisar 2012-08-07 13:25:34 UTC
This code:

sub foo {
    my $x if @_;
    return if @_;

    $x = 17;
    print $x, "\n";
    print sub { $x }->(), "\n";
    return;

}
foo(1); # make $x stale in all perl versions
foo;

produces errors and wrong output because it stales the $x:

17
Variable "$x" is not available at ./lexical_sub line 11.
Use of uninitialized value in print at ./lexical_sub line 11.


All perls since 5.10.1 are affected.

All Fedoras are affected.

Fixed in upstream by commit:

commit cae5dbbe30ba4a96ff5e570be0d90779f06fee71
Author: Father Chrysostomos <sprout>
Date:   Sat Aug 4 14:42:47 2012 -0700

    Close over stale vars in active subs

Comment 1 Petr Pisar 2012-09-11 11:06:44 UTC
This alone patch applied to 5.16.1 causes failures in t/op/closure.t. This patch pre-requires other patches. And actually lexical subroutines are experimental and upstream has not resolved all problems yet.

Comment 2 Petr Pisar 2012-09-11 12:01:25 UTC
I ported five other patches and it still needs other ones. They change internals of cloning contexts and opens series of another mistakes. This bug reports is not resolvable now. It will be fixed in next perl minior version (5.18).


Note You need to log in before you can comment on or make changes to this bug.