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 '__PACKAGE__' in debug mode do not return right package #16512
Comments
From @KES777Created by @KES777[DOC](https://perldoc.perl.org/functions/eval.html)
How to reproduce: $ cat Devel/DB.pm sub DB { 1; $ cat t.pl $ perl -d:DB t.pl Expected: Perl Info
|
From @iabynOn Thu, Apr 19, 2018 at 07:06:06AM -0700, KES wrote:
That paragraph says nothing about about the package an eval is executed; my $x = 'outer'; outputs: notDB-outer (which is what I expect).
I would expect DBmain. |
The RT System itself - Status changed from 'new' to 'open' |
From @KES777
Yes, this is right. I suppose it does. Because this is 'string eval' which:
The 'eval' in DB package
The first non-DB piece is 'main' package, thus __PACKAGE__ should return 'main' |
From @iabynOn Fri, Apr 20, 2018 at 01:17:53AM -0700, KES via RT wrote:
You are conflating two completely different issues. perl has a hack that affects how it looks up lexical (my) variables This has nothing to do with __PACKAGE__, which is static and completely |
From @KES777Yes, It is implemented in this way. But to my mind it would be more consistent Thus if we look at N frames up the `p __LINE__` will show user's script line and not debugger's eval. This is minor, but looks more expected Also when evaluating at users context, it is eval at first non-DB frame. Just like: 'eval EXPR, 0'. It would be cool if eval in debugger mode (-d) will accept second argument which means stack frame number from TOP. And evaluates given EXPR at given frame. This will be not so criminal to support it, because it already support 0 frame. Also this will simplify hacks like this: https://github.com/KES777/Devel-DebugHooks/blob/master/lib/Devel/DebugHooks/Commands.pm#L716 |
From @iabynOn Mon, Apr 23, 2018 at 01:24:11AM -0700, KES via RT wrote:
If I understand you correctly, you're wanting __LINE__etc to be changed Even so, I don't see how that will help make 'p __LINE__' in the
By 'eval in debugger mode', are you referring to the 'x' debugger command, I'm afraid I don't understand what you're proposing. -- |
From @KES777
No. Maybe change the value it is compiled into when this is 'eval' in DB package
I mean next: An eval '' executed within a subroutine defined in the DB package doesn't see the usual surrounding lexical scope, but rather the scope of **the first** non-DB piece (FRAMENUMBER=0) of code that called it. You can provide FRAMENUMBER to force eval see the second (FRAMENUMBER=1), the third (FREAMENUMBER=2) scope |
From @iabynOn Mon, Apr 23, 2018 at 07:14:08AM -0700, KES via RT wrote:
So, this: package DB { would output what about errors and warnings within the eval? Would they appear to come
It's not possible to give eval an optional second argument. Eval used as f(eval $x, 1); -- |
From @KES777
No. It would output: because inside do_foo the __PACKAGE__ is used without 'eval'
would it be reasonable eval_at/DB::eval_at? |
Migrated from rt.perl.org#133123 (status was 'open')
Searchable as RT133123$
The text was updated successfully, but these errors were encountered: