New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object instantiated/assigned inside of do { } block does not have DESTROY method called if assignment is the only action in the block #16676
Comments
From @cpanelrikusIf you have a do block in which the only action is declaring a lexical (Note: The sleep is optional and just for reassurance that there's not
However, putting anything at the beginning or the end of the block will
This type of "loop" block is unaffected:
The impact of this seems minimal, and I'm not completely sure this is a Replicated on:
Perl Info
|
From @jkeenanBehavior confirmed on perl-5.28.0. For the benefit of others who wish to confirm, I'm attaching the 4 variants. Thank you very much. -- |
From @jkeenanSimply inserting a 1; makes this work as expected. #!/usr/bin/env perl
use strict;
use warnings;
do { 1; my $obj = Obj->new(); };
sleep 2;
kill "KILL", $$;
package Obj;
sub new { return bless {}, __PACKAGE__; }
DESTROY { print "destroy called\n" }
|
From @jkeenanwith a second line, do{} works as expected. #!/usr/bin/env perl
use strict;
use warnings;
do { my $obj = Obj->new(); 1; };
sleep 2;
kill "KILL", $$;
package Obj;
sub new { return bless {}, __PACKAGE__; }
DESTROY { print "destroy called\n" }
|
From @jkeenanWithout do this works as expected. #!/usr/bin/env perl
use strict;
use warnings;
{ my $obj = Obj->new(); };
sleep 2;
kill "KILL", $$;
package Obj;
sub new { return bless {}, __PACKAGE__; }
DESTROY { print "destroy called\n" }
|
From @jkeenanThis code never displays "destroy called" #!/usr/bin/env perl
use strict;
use warnings;
do { my $obj = Obj->new(); };
sleep 2;
kill "KILL", $$;
package Obj;
sub new { return bless {}, __PACKAGE__; }
DESTROY { print "destroy called\n" }
|
The RT System itself - Status changed from 'new' to 'open' |
perl-all seems to indicate this has been broken back to at least 5.6.0 |
Migrated from rt.perl.org#133489 (status was 'open')
Searchable as RT133489$
The text was updated successfully, but these errors were encountered: