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

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

Thread Next
From:
Bernhard Wagner
Date:
September 6, 2016 06:09
Subject:
[perl #129203] wrong line number in error reported in while loop
Message ID:
rt-4.0.24-32452-1473085812-961.129203-75-0@perl.org
# New Ticket Created by  Bernhard Wagner 
# Please include the string:  [perl #129203]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129203 >


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.
# 
# 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)


Thread Next


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