Skip Menu |

This queue is for tickets about the Carp-Always CPAN distribution.

Report information
The Basics
Id: 75825
Status: resolved
Priority: 0/
Queue: Carp-Always

People
Owner: Nobody in particular
Requestors: n [...] shaplov.ru
Cc: ether [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.16



Subject: Carp::Always + strict => stict works wrong
Date: Fri, 16 Mar 2012 22:47:44 +0400
To: bug-Carp-Always [...] rt.cpan.org
From: Nikolay Shaplov <n [...] shaplov.ru>
When you use both Carp::Always and strict, strict stops properly detect the line number of not declared variables: ===================== #!/usr/bin/perl use strict; use Carp::Always; $z=1; print "the end\n"; ==================== This script will say Global symbol "$z" requires explicit package name at ./carp.pl line 16 through $z is mentioned at line 5. If you comment out use Carp::Always, strict will work properly and say about line 5 as it should. I do not think there can be an error in strict, error in Carp::Always is more probable in my opinion. If not, tell me, I will report this to strict maintainers :-)
On Fri Mar 16 14:48:53 2012, Shaplov wrote: Show quoted text
> > When you use both Carp::Always and strict, strict stops properly > detect the > line number of not declared variables: > ===================== > #!/usr/bin/perl > > use strict; > use Carp::Always; > $z=1; > > > > > > > > > > > print "the end\n"; > ==================== > This script will say > > Global symbol "$z" requires explicit package name at ./carp.pl line 16 > > through $z is mentioned at line 5. > > If you comment out use Carp::Always, strict will work properly and say > about > line 5 as it should. > > I do not think there can be an error in strict, error in Carp::Always > is more > probable in my opinion. If not, tell me, I will report this to strict > maintainers :-) >
I think this is a bug in perl, because caller() inside a $SIG{__DIE__} handler is returning the wrong line number. But I don’t understand why Carp::Always has to remove the line number passed in to the handler via the message in $_[0]. So maybe it’s a bug in both.
On Fri Mar 16 17:20:02 2012, SPROUT wrote: Show quoted text
> I think this is a bug in perl, because caller() inside a $SIG{__DIE__} > handler is returning the > wrong line number.
Actually, I don’t think it is. See my reasoning at <https://rt.perl.org/rt3/Ticket/Display.html? id=111982#txn-1109292>.
With the current release of Carp::Always the output of your test case script will now be: Global symbol "$z" requires explicit package name at f.pl line 5. Execution of f.pl aborted due to compilation errors. at f.pl line 16. The reported line 16 has to do with the intrincacies of warnings / errors emitted during compilation. But the main point is that Carp::Always doesn't eat part of the message anymore. So I will consider this issue as fixed (in the sense that this is probably the best we can do relying completely on Carp as Carp::Always does). For SPROUT, the reason for Carp::Always to fuss with the message coming from the handlers is two-fold: 1. to deal with the magic of die & warn that appends " at FILE line LINE.\n" when the last argument does not end with a newline 2. to deal with carp / croak / cluck / confess in verbose mode which appends stacktraces to the message If Carp::Always did nothing with the arguments passing thru the handlers, there would be duplicate tracebacks. Fortunately, with Carp::Always 0.16 the solution to suppress duplicate stacktraces is much better than the previous substitutions used and Carp::Always should be more useful from now on.