Skip to content

Commit 562985f

Browse files
committed
closure outside linking: test the reported test case
and a version with eval EXPR which will remain broken
1 parent 9059509 commit 562985f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/op/closure.t

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,4 +811,47 @@ sub {
811811
};
812812
test_ref_to_unavailable();
813813

814+
{
815+
# 22547
816+
fresh_perl_is(<<'EOC', "OK", {}, "RT #22547");
817+
use builtin qw(weaken);
818+
819+
my $wref;
820+
{
821+
my $x;
822+
my $subject = sub {
823+
$x = $_[0];
824+
825+
my $y;
826+
return sub { $y };
827+
};
828+
my $subscriber = {};
829+
weaken($wref = $subscriber);
830+
$subscriber->{foo} = $subject->($subscriber);
831+
}
832+
!defined $wref and print "OK";
833+
EOC
834+
835+
local $TODO = "still leaks with eval ''";
836+
fresh_perl_is(<<'EOC', "OK", {}, "RT #22547 with eval");
837+
use builtin qw(weaken);
838+
839+
my $wref;
840+
{
841+
my $x;
842+
my $subject = sub {
843+
$x = $_[0];
844+
845+
my $y;
846+
return sub { eval "1"; $y };
847+
};
848+
my $subscriber = {};
849+
weaken($wref = $subscriber);
850+
$subscriber->{foo} = $subject->($subscriber);
851+
}
852+
!defined $wref and print "OK";
853+
EOC
854+
}
855+
856+
814857
done_testing();

0 commit comments

Comments
 (0)