develooper Front page | perl.perl5.porters | Postings from March 2019

[perl #133895] caller(0) returns wrong line number when called fromsingle-stmt else{...}

From:
Chris Wagner via RT
Date:
March 19, 2019 19:35
Subject:
[perl #133895] caller(0) returns wrong line number when called fromsingle-stmt else{...}
Message ID:
rt-4.0.24-31776-1553024137-475.133895-15-0@perl.org
I can confirm this on 5.22.4 Cygwin.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if (0) {
        # # # millions of lines of spagetti code # #
        }
elsif ($bad) {
        # my $x; #un-comment and the problem goes away
        confess("HERE WE ARE"); # HERE WE ARE at /tmp/t2 line 8
}
HERE WE ARE at - line 7.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if ($bad - 1) {
        # # # millions of lines of spagetti code # #
        die;
}
elsif ($bad) {
        # my $x; #un-comment and the problem goes away
        confess("HERE WE ARE 13"); # HERE WE ARE at /tmp/t2 line 8
}
HERE WE ARE 13 at - line 7.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if ($bad - 1) {
        # # # millions of lines of spagetti code # #
        die;
}
elsif ($bad) {
        my $x; #un-comment and the problem goes away
        confess("HERE WE ARE 13"); # HERE WE ARE at /tmp/t2 line 8
}
HERE WE ARE 13 at - line 13.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if ($bad - 1) {
        # # # millions of lines of spagetti code # #
        die;
}
elsif ($bad) {
        # my $x; #un-comment and the problem goes away
        1;
        confess("HERE WE ARE 14"); # HERE WE ARE at /tmp/t2 line 8
}
HERE WE ARE 14 at - line 14.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if ($bad - 1) {
        # # # millions of lines of spagetti code # #
        die;
}
elsif ($bad) {
        # my $x; #un-comment and the problem goes away
        confess("HERE WE ARE 13"); # HERE WE ARE at /tmp/t2 line 8
        1;
}
HERE WE ARE 13 at - line 13.


$ perl
use strict;
use warnings;
sub u(_) { defined($_[0]) ? $_[0] : "undef" }
sub f { warn((join ", ", map{u} (caller(0))), "\n"); }
use Carp;
my $bad = 1;
if ($bad - 1) {
        # # # millions of lines of spagetti code # #
        die;
}
elsif ($bad) {
        confess("HERE WE ARE 13"); # HERE WE ARE at /tmp/t2 line 8
}
HERE WE ARE 13 at - line 7.



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



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