Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.93k stars 549 forks source link

Report better anonymous hash error line number #17386

Open jidanni opened 4 years ago

jidanni commented 4 years ago

There are three anonymous hashes, at lines 2, 6, and 11.

$ nl e.pl 1 my @AoH = ( 2 { 3 Lead => "fred", 4 Friend => "barney", 5 }, 6 { 7 Lead => "george", 8 Wife => "jane", 9 Son => "elroy", 10 }, 11 { 12 Lead => "homer", 13 99, 14 Wife => "marge", 15 Son => "bart", 16 } 17 ); 18 @AoH=(); #to avoid 'only used once' warning $ perl -w e.pl Odd number of elements in anonymous hash at e.pl line 1.

It would be better if it said the problem was at line 13, or at least line 11.

YES, it makes sense that it says line 1. BUT, it could make more / better / enhanced sense.

v5.30

iabyn commented 4 years ago

Perl currently records line number information once per statement rather than per op. This leads to a lot of bugs to do with line number reporting for warnings and errors. This is a well-known issue and needs fixing, but no-one has had the time or inclination yet.