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
eval in package DB can't see caller's lexicals in certain cases #16230
Comments
From @jimavThis is a bug report for perl from jim.avera@gmail.com, I have a debugging library which uses eval in package DB to However lexicals are sometimes not accessible, and it seems to In the example below, if there is any statement following Can someone shed light on this? #!/usr/bin/perl package DB; sub my_interpolate($) { package main; my %hash = (A => 100, B => 200); while (my ($key, $value) = each %hash) { #1; # un-comment this and the problem vanishes! Flags: Site configuration information for perl 5.24.1: Configured by Debian Project at Sat Mar 18 17:00:39 UTC 2017. Summary of my perl5 (revision 5 version 24 subversion 1) configuration: Platform: Locally applied patches: @INC for perl 5.24.1: Environment for perl 5.24.1: |
From zefram@fysh.org
It's a regression in 5.13.7. Bisect fingers commit
No. -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgThis issue is about nextstate ops being elided. A simple failing case is: $ perl5.26.0 -lwe '{ package DB; sub f { print eval "\$x" ? "ok" : "fail"; } } if(++(my $x)) { DB::f(); }' If you look at the optree, you'll see that the body of the if() had a 6 <;> nextstate(main 5 -e:1) v:{ ->7 This matters because the eval from DB-land goes looking up the call chain Note that $x is nevertheless in scope for the subroutine call as judged Adding a no-op statement such as "1;" inside the block, either before I said this was a regression in 5.13.7, but that's not entirely correct. If the downside of this problem were only evals from the DB package $ perl5.26.0 -lwe 'sub f { print +((caller(0))[10] || {})->{foo} || "fail"; } if(++(my $x)) { BEGIN { $^H{foo} = "ok"; } f(); }' Weirdly, although the while() version of the eval problem didn't occur So generally there's going to have to be less nulling of nextstate ops, -zefram |
Migrated from rt.perl.org#132414 (status was 'open')
Searchable as RT132414$
The text was updated successfully, but these errors were encountered: