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
Code blessed where it shouldn't. #2027
Comments
From abigail@arenanetworks.comCreated by abigail@arena-i.comConsider the following code: #!/opt/perl/bin/perl -w use strict; sub new { for my $i (1 .. 2) { __END__ This will print something like: CODE(0x816454c) that is, the second time new () is called, the code ref is already main -> new (sub {$i}); While one can say it might not really matter that $code is already Abigail Perl Info
|
From p5p@spam.wizbit.beThe reason why this is happening is discussed in #3306. (Not exactly the same problem but related.) |
FWIW, I dont get the reference to #3306 mentioned in this thread. It doesn't seem to be related at all. This bug is still present in the blead perl. I would describe it differently than is done in this ticket. Because the code block is empty we are "optimizing" it to use the same CODE block each time. But that is wrong. Consider a different version of this code:
so we arent getting distinct sub{}'s here, we are getting one. This code should output A::DESTROY, B::DESTROY. Simple statement: this optimization is broken. |
That's a mis-link from the RT to GitHub migration. The actual link is #2028, which seems to have been closed by mistake. |
Thank you @haarg. Can you tell me how you found that? |
Migrated from rt.perl.org#3305 (status was 'open')
Searchable as RT3305$
The text was updated successfully, but these errors were encountered: