On Fri, 28 Jan 2011, Britton Kerin wrote:
There is some strange bug that causes line numbers in errors coming
from perl to come out wrong in some circumstances.
This code:
perl <<END_PERL
# line 3 line_number_test.vim
if ( 0 ) {
die "I don't cause trouble because I'm all on one line";
}
die "I am really line 8";
behaves as expected when openened and :so %.
This code ends up wrongly reporting the error as being on line 10:
perl <<END_PERL
# line 3 line_number_test.vim
if ( 0 ) {
die
"I DO cause trouble perhaps because I'm not all on one line?";
}
die "I am really line 9";
The bug is not in perl because this script:
#!/usr/bin/perl -w
# line 3
use strict;
if ( 0 ) {
die
"I don't happen";
}
die "I do happen";
works as expected.
The problem is the same for compile time errors (e.g. $foo = "bar"
with $foo undeclared and warnings fatal) as for run-time ones.
The scripts are attached in case anyone wants to try them.
I suspect that vim is getting clever and rewriting the die code
somehow and accidently adding a line in some cases or something, but I
haven't looked into it at all.
I'm really hoping someone can tell me what's going on or where to
look. I just released
http://www.vim.org/scripts/script.php?script_id=3406 and
http://www.vim.org/scripts/script.php?script_id=3411 but I'll have to
pull them if they are inevitably going to commit that most unholy
crime of lying to people who are trying to debug.
I doubt Vim would try anything clever with rewriting Perl code. That
way lies madness.
Both of your tests work fine for me under stock VIM 7.3. (7.3.000, I
guess). Same results with and without -u NONE -i NONE -N (so, with and
without the various plugins I have installed).
Do the tests fail for you without the line directives? What if you move
them to just above the fatal 'die'? (in which case the line number
reported should match the comment exactly) Just wondering if something
else in your Vim is altering the evaluated Perl code and/or whether
line-number reporting is correct without the line directives.
I was surprised to not get an error about the unclosed END_PERL heredoc.
(But I don't use Perl from Vim, so maybe it's more lax about it.)
How about line-endings (really doubtful, but checking)? I'm under
Linux, so bare LFs.
The fact that it works properly under "real" perl might not have much
bearing on diagnosing this. Often libperl.so is a separately-compiled
library that Vim would've been linked against, so running commandline
perl wouldn't even necessarily be the same version of perl that Vim
could be picking up.
After installing your plugin (3406, the line-directive adding one), I
notice a few things:
1. It seems to strip the last line of the file regardless of its
contents.
2. As part of that, it removes the closing heredoc marker.
perl <<END_PERL
## some perl stuff
END_PERL
becomes:
perl <<END_PERL
# line 3 filename
## some perl stuff
3. It seems to add a second line-directive even if one already exists,
which kind of negates its purpose (end up with two "# line 3"
directives, the second of which occurs before line 4, so off-by-one).
But, excepting #3 (the doubled line-directive) the reported line numbers
still seem correct.
--
Best,
Ben
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php