develooper Front page | perl.perl5.porters | Postings from September 2016

[perl #129203] wrong line number in error reported in while loop

Thread Previous
From:
James E Keenan via RT
Date:
September 5, 2016 15:07
Subject:
[perl #129203] wrong line number in error reported in while loop
Message ID:
rt-4.0.24-2854-1473088033-1977.129203-15-0@perl.org
On Mon Sep 05 07:30:12 2016, bitcard.org@bernhardwagner.net wrote:
> The error is reported with the wrong line number (10 instead of 8).
> This error comes from a longer example, where the error was reported
> on the last line within the while-block.
> 
> #!/usr/bin/env perl
> use strict;
> use warnings;
> 
> my @arr = (1, undef);
> 
> my $i = 0;
> while( $arr[$i] > 0 ) {
>   print $i, $/;
>   $i++; # line 10
> }
> 
> # Causes error:
> # Use of uninitialized value $arr[1] in numeric gt (>) at ./while2.pl
> line 10.
> # However, I'd expect this error to be indicated with line 8, not 10.
>  #

This is probably not easily fixable.  See, e.g., discussion of a similar issue in Porting/todo.pod in the section headed "eliminate incorrect line numbers in warnings".

> # error reproduced for perls:
> # v5.18.2 on Ubuntu 14.04.4
> # 5.23.9 on OSX 10.11.6 (El Capitan)
> # 5.23.7 on OSX 10.11.6 (El Capitan)
> # 5.16.3 on OSX 10.11.6 (El Capitan)
> # 5.25.4 on OSX 10.11.6 (El Capitan)


-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=129203

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About