Branch: refs/heads/blead
Home: https://github.com/Perl/perl5
Commit: ffa804ca27fa678334fd13757228bf841ffb9c1f
https://github.com/Perl/perl5/commit/ffa804ca27fa678334fd13757228bf841ffb9c1f
Author: Richard Leach <[email protected]>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
M lib/perl5db.t
M op.c
M pod/perldelta.pod
M t/op/caller.t
M toke.c
Log Message:
-----------
Note (yyl_leftcurly) & restore (newATTRSUB_x) line numbers for anon subs
Declaring an anonymous subroutine in the middle of a statement is likely
to result in an inaccurate line number being stored in the COP preceding
the statement. This is because line number information is discarded
during parsing and creation of the anonymous subroutine.
This commit attempts to store and restore a more accurate line number
for the COP. This will improve the accuracy of line numbers emitted by
diagnostic messages and `caller()`. **_Tests containing hardcoded line
numbers may require updating as a result of this commit._**
This (previously) TODO test from _caller.t_ shows the difference:
```
sub tagCall {
my ($package, $file, $line) = caller;
print "$line\n";
}
tagCall # Line number 6 correctly reported before & after
"abc";
tagCall # Line number 9 correctly reported with this commit
sub {}; # Line number 10 incorrectly reported previously
```
Changes in line numbering could also affect where breaking on a function
occurs in the perl debugger. This can be seen in the included change to
_perl5db.t_, where breaking on entry to `problem()` now occurs at the
start of the subroutine, rather than after the anonymous subroutine
declaration:
```
sub problem {
$SIG{__DIE__} = sub { # Breaking on problem() now lands here
die "<b problem> will set a break point here.\n";
}; # Breaking on problem() used to land here
```
To unsubscribe from these emails, change your notification settings at
https://github.com/Perl/perl5/settings/notifications