diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-11 21:28:53 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-11 21:29:46 -0800 |
commit | c5e6a3c74b2fe93aae700ce59ef0ad8c70ad1bd6 (patch) | |
tree | 83f39ad2ff2fa0d81967f91ab933a3abcddfff9f /t/op/closure.t | |
parent | 5a8cd187c670a790aa65012a84cc1b7898b5ff02 (diff) | |
download | perl-c5e6a3c74b2fe93aae700ce59ef0ad8c70ad1bd6.tar.gz |
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.
Diffstat (limited to 't/op/closure.t')
-rw-r--r-- | t/op/closure.t | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/t/op/closure.t b/t/op/closure.t index 569724f62d..9a4e50dc2a 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(); |