Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong line number in error reported in while loop #15589

Open
p5pRT opened this issue Sep 5, 2016 · 3 comments
Open

wrong line number in error reported in while loop #15589

p5pRT opened this issue Sep 5, 2016 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 5, 2016

Migrated from rt.perl.org#129203 (status was 'open')

Searchable as RT129203$

@p5pRT
Copy link
Author

p5pRT commented Sep 5, 2016

From bitcard.org@bernhardwagner.net

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)

@p5pRT
Copy link
Author

p5pRT commented Sep 5, 2016

From @jkeenan

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)

@p5pRT
Copy link
Author

p5pRT commented Sep 5, 2016

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants