develooper Front page | perl.perl5.porters | Postings from December 2011

[perl #19455] -Mdiagnostics leaking on Foo::$bar

From:
Father Chrysostomos via RT
Date:
December 26, 2011 17:58
Subject:
[perl #19455] -Mdiagnostics leaking on Foo::$bar
Message ID:
rt-3.6.HEAD-14510-1324951127-550.19455-15-0@perl.org
On Sun Sep 12 20:23:46 2010, sprout wrote:
> On Thu Dec 26 13:10:21 2002, nicholas wrote:
> > 
> > This is a bug report for perl from nick@ccl4.org,
> > generated with the help of perlbug 1.34 running under perl v5.8.0.
> > 
> > 
> > -----------------------------------------------------------------
> > [Please enter your report here]
> > 
> > $ perl5.8.0 -Mdiagnostics -e 'Foo::$bar'
> > Bad name after Foo:: at -e line 1 (#1)
> >     (F) You started to name a symbol by using a package prefix, and
> >    then
> >     didn't finish the symbol.  In particular, you can't interpolate
> >    outside
> >     of quotes, so
> > 
> >         $var = 'myvar';
> >         $sym = mypack::$var;
> > 
> >     is not the same as
> > 
> >         $var = 'myvar';
> >         $sym = "mypack::$var";
> > 
> > Uncaught exception from user code:
> >         Bad name after Foo:: at -e line 1.
> > 
> > 
> > 
> > What is that line "Uncaught exception from user code" doing there?
> > 
> > diagnostics.pm seems to have managed to capture the error output, as
> >    it's
> > given the correct text from perldiag.pod, yet it then restates the
> >    same
> > error message as being a user message. I see the same undesirable
> >    behaviour
> > on perl5.005_03
> > 
> > Other warnings seem to be caught completely, such as:
> > 
> > $ perl -Mdiagnostics -e '2'
> > Useless use of a constant in void context at -e line 1 (#1)
> > ...
> 
> Looking at the source of diagnostics.pl, it seems to me that this was
> intentional. Fatal errors give the ‘Uncaught exception’ message (only
> outside of an eval, though). Warnings don’t.

I’ve looked at this again and come to the conclusion that this is not a
bug.  To avoid being obnoxious, diagnostics.pm only prints each
description once.  Some messages can be both errors and warnings, so it
makes sense to keep warnings and errors under the same category.

Therefore the diagnostic message that appears does not replace, but
supplements the error message.

The ‘Uncaught exception’ is the error message proper.

$ ./perl -Ilib -Mdiagnostics -e 'warn "Died"; warn "foo"; die'
Died at -e line 1 (#1)
    (F) You passed die() an empty string (the equivalent of die "") or
    you called it with no args and $@ was empty.
    
foo at -e line 1.
Uncaught exception from user code:
	Died at -e line 1.

It is followed by a backtrace, the format of which was a bit screwy. 
(Originally diagnostics.pm did confess("Bailing out") to avoid having a
left-justified ‘ at ... line ...’.  But that got remove a long time ago,
and I don’t know why.)  I’ve modified things with commit 2dde04676 (the
last paragraph of whose commit message is a little misleading, since I
was still a little confused myself) so the output looks reasonable and
does not repeat the first file and line number.

-- 

Father Chrysostomos


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



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