develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #133123] eval '__PACKAGE__' in debug mode do not return rightpackage

Thread Previous | Thread Next
From:
KES via RT
Date:
April 25, 2018 10:04
Subject:
[perl #133123] eval '__PACKAGE__' in debug mode do not return rightpackage
Message ID:
rt-4.0.24-31301-1524650673-1051.133123-15-0@perl.org
> package DB {
>     sub do_foo  { print __PACKAGE__, "\n" }
>     sub do_eval { print eval '__PACKAGE__', "\n" }
> }
> do_foo();
> do_eval();
> 
> would output
>     main
>     DB
> 
No. It would output:
    DB
    main

because inside do_foo  the __PACKAGE__ is used without 'eval'
and inside do_eval '__PACKAGE__' is evaled in first non-DB


> what about errors and warnings within the eval? Would they appear to
> come
> from within the eval, or from the first non-DB caller.
I did not think about that, if expression is eval'ed at first non-DB caller thus
errors and warning should appear as from the first non-DB caller
probably using Current::Package::__ANON__[local/lib/perl5/Path/To/Module.pm:15] form

> f(eval $x, 1);

would it be reasonable eval_at/DB::eval_at?


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133123

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About