Subject: | Devel::Declare corrupts line numbering |
If running attached code as
perl bug.pl
(you'll need A.pm too), it says
Possible precedence issue with control flow operator at bug.pl line 15.
even though the warning belongs to line 26
Subject: | A.pm |
package A;
use strict;
use warnings;
use Devel::Declare;
sub parser_sub
{
my ( $param, $decl, $offset) = @_;
my $l = Devel::Declare::get_linestr();
substr($l, $offset + length($decl), 0) = ' ' . $param . ', sub';
Devel::Declare::set_linestr($l);
}
sub import
{
my $pkg = caller;
Devel::Declare->setup_for( $pkg, {
'test' => { const => sub { parser_sub( '$param', @_ ) } }
});
{
no strict 'refs';
*{$pkg."::test"} = sub ($&) { };
}
}
1;
Subject: | bug.pl |
#! /usr/bin/perl -w
use strict;
use warnings;
use lib '.';
use A;
our $param;
if(1) {
# bad
# bad
# bad
# bad
# bad
# bad
# bad
# bad
# bad
# bad
}
test { };
sub foo
{
return
can()
or # <-- warning is here, actually
die;
}
1;