Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 530b71671f0f203f87fc7119874ea7380476eb06
      
https://github.com/Perl/perl5/commit/530b71671f0f203f87fc7119874ea7380476eb06
  Author: Richard Leach <[email protected]>
  Date:   2026-07-20 (Mon, 20 Jul 2026)

  Changed paths:
    M pp_hot.c
    M t/lib/warnings/9uninit
    M t/run/switches.t

  Log Message:
  -----------
  pp_unstack - set PL_curcop for better condition line number accuracy

Diagnostic messages triggered by the contents of a loop condition have
tended to show inaccurate line numbers, as the COP in effect usually
pertains to a statement inside the loop body. Sometimes deep inside
the loop body.

This long-standing example would warn about `Use of uninitialized value
$c in numeric eq (==) at - line 10.`, when the correct location is line 5:
```
use warnings;

my $c;
my $d = 1;
while ($c == 0 && $d) {
  # a
  # few
  # blank
  # lines
  undef $d;
}
```

This commit tweaks `pp_unstack` to set `PL_curcop` to the last valid
COP prior to loop entry, which is usually going to have a line number
closer to where the loop condition exists in the source code.



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to