Skip to content
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

bug in do-block scoping #16785

Open
p5pRT opened this issue Dec 10, 2018 · 1 comment
Open

bug in do-block scoping #16785

p5pRT opened this issue Dec 10, 2018 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Dec 10, 2018

Migrated from rt.perl.org#133720 (status was 'new')

Searchable as RT133720$

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2018

From @haukex

Dear P5P,

The fourth of these three examples seems inconsistent, there appears to
be something funky going on with the scoping - it seems to me they
should all output the same thing, i.e. the object should be being
destroyed at the end of the do{}'s scope in the fourth example.

$ perl -e 'sub DESTROY{print "Foo"} { my $x=bless{}}; print "Bar"'
FooBar
$ perl -e 'sub DESTROY{print "Foo"} do{ bless{}}; print "Bar"'
FooBar
$ perl -e 'sub DESTROY{print "Foo"} do{1;my $x=bless{}}; print "Bar"'
FooBar
$ perl -e 'sub DESTROY{print "Foo"} do{ my $x=bless{}}; print "Bar"'
BarFoo

First reported here by "vr"​: https://www.perlmonks.org/?node_id=1227033

This behavior is the same in 5.6.2 thru 5.28.0 (older versions not tested).

Thanks, Regards,
-- Hauke D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants