In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/c5e6a3c74b2fe93aae700ce59ef0ad8c70ad1bd6?hp=5a8cd187c670a790aa65012a84cc1b7898b5ff02>
- Log ----------------------------------------------------------------- commit c5e6a3c74b2fe93aae700ce59ef0ad8c70ad1bd6 Author: Father Chrysostomos <[email protected]> Date: Tue Nov 11 21:28:53 2014 -0800 Test reference to unavailable lexical variable This is related to #123172. v5.21.3-644-ge52eb89 inadvertently fixed this old bug, which was prob- ably introduced by the jumbo closure patch: $ perl5.8.9 -le 'sub { my $f; BEGIN { $ref = \$f; $f = 7; $$ref = 8; print $f } }' 8 $ perl5.10 -le 'sub { my $f; BEGIN { $ref = \$f; $f = 7; $$ref = 8; print $f } }' 7 $ perl5.20.1 -le 'sub { my $f; BEGIN { $ref = \$f; $f = 7; $$ref = 8; print $f } }' 7 $ perl5.21.5 -le 'sub { my $f; BEGIN { $ref = \$f; $f = 7; $$ref = 8; print $f } }' 8 \ was returning a *copy* of its referent if the latter closed over an anonymous subâs stale variable. ----------------------------------------------------------------------- Summary of changes: t/op/closure.t | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/op/closure.t b/t/op/closure.t index 569724f..9a4e50d 100644 --- a/t/op/closure.t +++ b/t/op/closure.t @@ -815,4 +815,14 @@ SKIP: { 'closures in source filters do not interfere with pad names'; } +sub { + my $f; + sub test_ref_to_unavailable { + my $ref = \$f; + $$ref = 7; + is $f, 7, 'taking a ref to unavailable var should not copy it'; + } +}; +test_ref_to_unavailable(); + done_testing(); -- Perl5 Master Repository
