pp_unstack - set PL_curcop for better condition line number accuracy#24389
pp_unstack - set PL_curcop for better condition line number accuracy#24389richardleach wants to merge 1 commit into
Conversation
|
This p.r. is failing one test on each of the two Windows actions (msvc143 and mingw64). When I see a test failure in one but not both of these two actions, I assume it's a resource problem and re-start the action. That often gets the action to PASS. But when I see failures in both, I suspect a problem with the p.r. itself. Can you investigate? Thanks. |
|
The test looks like it might effectively be skipped everywhere else - presumably these conditions are very common: Line 3 does look correct, so the test will need changing. I might close this PR in favour of a more encompassing PR that adds an |
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.
087f770 to
9409dfc
Compare
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:This commit tweaks
pp_unstackto setPL_curcopto 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.No new tests added, as the three TODO tests that now pass seem ample.
Closes #15589
Closes #16574