Skip to content

Commit

Permalink
closure outside linking: test the reported test case
Browse files Browse the repository at this point in the history
and a version with eval EXPR which will remain broken
  • Loading branch information
tonycoz committed Oct 1, 2024
1 parent f4530bf commit c513c2f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions t/op/closure.t
Original file line number Diff line number Diff line change
Expand Up @@ -811,4 +811,47 @@ sub {
};
test_ref_to_unavailable();

{
# 22547
fresh_perl_is(<<'EOC', "OK", {}, "RT #22547");
use builtin qw(weaken);
my $wref;
{
my $x;
my $subject = sub {
$x = $_[0];
my $y;
return sub { $y };
};
my $subscriber = {};
weaken($wref = $subscriber);
$subscriber->{foo} = $subject->($subscriber);
}
!defined $wref and print "OK";
EOC

local $TODO = "still leaks with eval ''";
fresh_perl_is(<<'EOC', "OK", {}, "RT #22547 with eval");
use builtin qw(weaken);
my $wref;
{
my $x;
my $subject = sub {
$x = $_[0];
my $y;
return sub { eval "1"; $y };
};
my $subscriber = {};
weaken($wref = $subscriber);
$subscriber->{foo} = $subject->($subscriber);
}
!defined $wref and print "OK";
EOC
}


done_testing();

0 comments on commit c513c2f

Please sign in to comment.