-
Notifications
You must be signed in to change notification settings - Fork 553
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 '$foo' in package DB called from lexical sub can not see closure values or globals #19370
Comments
|
This looks like a consequence of a0d2bbd. This broke the CvOUTSIDE() links from the inner sub to the outer sub, so the outer names weren't visible from the inner sub, unless the inner sub has an eval or the debugger is enabled. The documentation for eval doesn't require that the debugger be enabled, so this is definitely a bug. I haven't worked out a fix yet, given this works if the inner sub is anonymous, I suspect some |
|
Actually it happens for anonymous subs too, if that sub is a closure: Comments out the So my speculation that including CvLEXICAL() subs was incorrect. If I make setting CvOUTSIDE() for the clone unconditional, as it was before a0d2bbd, both the lexical inner sub and the anonymous closure work. At this point I think the change from a0d2bbd is just broken, this was a fix for #11286, we need the CvOUTSIDE() links to implement this documented (in 2002) behaviour. @Leont and @iabyn both commented on the original ticket. @iabyn wrote the original change d819b83 that implemented this visibility. |
But they do need CvOUTSIDE() for eval-in-package-DB's scope magic to work correctly. This also incidentally fixes a TODO Deparse, since the CvOUTSIDE is now available Fixes Perl#19370 aka rt89544 This breaks Perl#11286, but I don't think that's fixable without breaking eval-in-DB's special scope behaviour. This reverts (most of) commit a0d2bbd.
But they do need CvOUTSIDE() for eval-in-package-DB's scope magic to work correctly. This also incidentally fixes a TODO Deparse, since the CvOUTSIDE is now available Fixes Perl#19370 aka rt89544 This breaks Perl#11286, but I don't think that's fixable without breaking eval-in-DB's special scope behaviour. This reverts (most of) commit a0d2bbd.
But they do need CvOUTSIDE() for eval-in-package-DB's scope magic to work correctly. This also incidentally fixes a TODO Deparse, since the CvOUTSIDE is now available Fixes #19370 aka rt89544 This breaks #11286, but I don't think that's fixable without breaking eval-in-DB's special scope behaviour. This reverts (most of) commit a0d2bbd.
|
The fix for this is being reverted. |
This reverts commit 386907f. Reinstates the behaviour of CV outside references from 5.38, fixing Perl#22547 Breaks Perl#19370
Perl v5.30.0
eval "string" in package DB is supposed to be evaluated in the nearest non-DB context, useful for debug tools. However when code in package DB is called from a nested lexical ("my") sub, only the lexicals in the innermost sub are visible; globals and lexicals in enclosing scopes can no longer be accessed.
(This may seem obscure, but it is important to me because I use some debugging tools which depend on eval in package DB being able to see user-defined lexicals).
The output from the following script is:
and here is the script:
The text was updated successfully, but these errors were encountered: