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

error line number reported wrong when using here documents #226

Closed
p5pRT opened this issue Jul 25, 1999 · 10 comments
Closed

error line number reported wrong when using here documents #226

p5pRT opened this issue Jul 25, 1999 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 25, 1999

Migrated from rt.perl.org#1034 (status was 'rejected')

Searchable as RT1034$

@p5pRT
Copy link
Author

p5pRT commented Jul 25, 1999

From @jhi

The following behavior is arguably both wrong and right, I'm for the
moment arguing for the former.

In here-documents an error (I think whichever error, that is of no
concern here, I think) is reported to the line where the here-doc
begins. If the doc is large, this can be rather frustrating.

The following example works only for _5X which have the utf8 pragma,
this is where I met this problem. The 8-bit adiaereses (if some mail
gateway has eaten your high bit, the middle line of the here-doc is
bär in HTML-speak) is rightfully reported is malformed UTF-8
character (no problem in there, utf8 is right in reporting that), but
the error is reported for the line where the here-doc begins, not
to the line where the problem is.

The code​:

$x = <<EOF;
foo
bär
zog
EOF
print $x, "\n";

and the result​:

./perl -Ilib -Mutf8 -w X
Malformed UTF-8 character at X line 1.
foo
bär
zog

Perl Info


Site configuration information for perl 5.00557:

Configured by jhi at Sun Jul 25 18:53:30 EET DST 1999.

Summary of my perl5 (revision 5.0 version 5 subversion 57) configuration:
  Platform:
    osname=dec_osf, osvers=4.0, archname=alpha-dec_osf
    uname='osf1 alpha.hut.fi v4.0 878 alpha '
    config_args='-ders'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    use64bits=undef usemultiplicity=undef
  Compiler:
    cc='cc', optimize='-O4', gccversion=
    cppflags='-std -ieee -D_INTRINSICS -DLANGUAGE_C'
    ccflags ='-std -fprm d -ieee -D_INTRINSICS -DLANGUAGE_C'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=8, ptrsize=8, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =''
    libpth=/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib
    libs=-lgdbm -ldbm -ldb -lm -lrt
    libc=, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-rpath,/usr/local/lib/perl5/5.00557/alpha-dec_osf/CORE'
    cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -msym -s'

Locally applied patches:
    


@INC for perl 5.00557:
    lib
    /u/vieraat/vieraat/jhi/Perl/lib
    /usr/local/lib/perl5/5.00557/alpha-dec_osf
    /usr/local/lib/perl5/5.00557
    /usr/local/lib/site_perl/5.00557/alpha-dec_osf
    /usr/local/lib/site_perl
    .


Environment for perl 5.00557:
    HOME=/u/vieraat/vieraat/jhi
    LANG=C
    LANGUAGE (unset)
    LC_ALL=fi_FI.ISO8859-1
    LC_CTYPE=fi_FI.ISO8859-1
    LD_LIBRARY_PATH=/u/vieraat/vieraat/jhi/pp4/cfgperl
    LOGDIR (unset)
    PATH=/u/vieraat/vieraat/jhi/Perl/bin:/u/vieraat/vieraat/jhi/.s:/u/vieraat/vieraat/jhi/.b/OSF1:/c/bin:/p/bin:/p/adm/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/ccs/bin:/usr/lib:/etc:/lib:/p/X6/bin:/p/X5/bin:/usr/bin/X11:/usr/lbin:/usr/sbin/acct:/usr/tcb/bin:/tcb/bin:/usr/field:/u/vieraat/vieraat/jhi
    PERLLIB=/u/vieraat/vieraat/jhi/Perl/lib
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From adam@maia.netsonic.net

Created by adam@netsonic.net

After upgrade, a reference in a script for a html footer such as this

<small><small>E-mail​: 
webmaster@​buscout.com</small></small></font></td>

worked flawlessly in perl 5.0004 after upgrade, it was required to have
this syntax in order to work​:

<small><small>E-mail​: 
webmaster\@​buscout.com</small></small></font></td>

Now the error reported as when run from command line​:

In string, @​buscout now must be written as \@​buscout at ./test.cgi line 13, near "@​buscout"
Execution of ./test.cgi aborted due to compilation errors.

yet this line is nowhere near line 13 but at line 87

line 13 is
print <<EndOfHTML;

Dont know if there is a backward compat issue here or an oversight.. thanks for all your efforts.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.0:

Configured by adam at Tue Apr 18 10:06:21 CDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=freebsd, osvers=2.2.8-release, archname=i386-freebsd
    uname='freebsd maia.netsonic.net 2.2.8-release freebsd 2.2.8-release #0: wed jul 21 15:36:35 cdt 1999 root@maia.netsonic.com:usrsrcsyscompilemaia i386 '
    config_args='-de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=2.7.2.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lm -lc -lcrypt
    libc=/usr/lib/libc.so.3.1, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/i386-freebsd
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i386-freebsd
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/root/bin
    PERL_BADLANG (unset)
    SHELL=/bin/csh


@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From [Unknown Contact. See original ticket]

On Apr 18, Adam Simpson said​:

<small><small>E-mail​: 
webmaster\@​buscout.com</small></small></font></td>

In string, @​buscout now must be written as \@​buscout at ./test.cgi line 13, near "@​buscout"
Execution of ./test.cgi aborted due to compilation errors.

yet this line is nowhere near line 13 but at line 87

line 13 is
print <<EndOfHTML;

Your quoted string starts at line 13. Take this as another example of
when line numbers may not be as you expect​:

  #!/usr/bin/perl -w
  if (0
  or 0 * $foo
  or 0 * $bar
  or 1) { print "ok" }

Name "main​::foo" used only once​: possible typo at - line 4.
Name "main​::bar" used only once​: possible typo at - line 5.
Use of uninitialized value at - line 2.
Use of uninitialized value at - line 2.

While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5,
it reads your entire if statement as one line (please, someone, give a
more suitable explanation of that).

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From [Unknown Contact. See original ticket]

On Apr 18, Jeff Pinyan said​:

Your quoted string starts at line 13. Take this as another example of

As O​::Deparse shows me​:

jeffp@​friday [12​:54pm] ~ #436> perl -MO=Deparse
print << "END";
testing
this
out
$$ right now
END
- syntax OK
print "testing\nthis\nout\n$$ right now\n";

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From [Unknown Contact. See original ticket]

Jeff Pinyan writes​:

While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5,
it reads your entire if statement as one line (please, someone, give a
more suitable explanation of that).

Diagnostic messages read the
line-number-of-currently-executed-chunk-of-code from some memory
location. This memory location should be reset when flow of execution
winds around. It is reset at the beginning of each statement.

Resetting it more often would slow things down, keeping the
line-number at each opcode would take a lot of memory.

Hope this helps,
Ilya

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From [Unknown Contact. See original ticket]

Ilya Zakharevich <ilya@​math.ohio-state.edu> writes​:
|| Jeff Pinyan writes​:
|| > While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5,
|| > it reads your entire if statement as one line (please, someone, give a
|| > more suitable explanation of that).
||
|| Diagnostic messages read the
|| line-number-of-currently-executed-chunk-of-code from some memory
|| location. This memory location should be reset when flow of execution
|| winds around. It is reset at the beginning of each statement.
||
|| Resetting it more often would slow things down, keeping the
|| line-number at each opcode would take a lot of memory.

If the diagnostic also has access to the current opcode structure,
and if there are a few bits available in the opcode structure,
it could contain an offset from the line number of the beginning
of the statement. If the offset was 3 bits, the value 7 would
mean​:

  "on or after line " . ($n+7) . " in the statement starting on line $n"
 
Values 1..6 of OFFSET would mean​:

  "on line " . ($n+OFFSET) . " in the statement starting on line $n"

And a value of 0 would issue​:

  "on line $n"

Since statements are usually very short (usually one line), this
would allow almost all diagnostics to be accurate to the position
of the opcode as well as noting the line number that starts the
statement.

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2004

From @schwern

This bug is not specific to here-docs but to any string.

[~] perl -w
my $bar = undef;
my $foo = qq{ # line 4
basset
hounds
got
long
$bar
and
such
};
Use of uninitialized value in concatenation (.) or string at - line 2.

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2004

From @schwern

[schwern - Fri Jun 25 14​:40​:49 2004]​:
my $foo = qq{ # line 4

Ignore that comment.

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2008

From p5p@spam.wizbit.be

Won't be fixed.

Relevant p5p messages​:
  http​://www.nntp.perl.org/group/perl.perl5.porters/2008/04/msg136273.
html
  http​://www.nntp.perl.org/group/perl.perl5.porters/2008/04/msg136277.
html

Comments​:

#!/usr/bin/perl -l

use strict;
use warnings;

my $foo;

my $x = <<EOF;
foo
$foo
zog
EOF
__END__
Output​:
Use of uninitialized value in concatenation (.) or string at a.pl
line 8.

Where one might expect​:
Use of uninitialized value in concatenation (.) or string at a.pl
line 10.
(the line with $foo)

Won't fix. The string (or heredoc) is seen as one token.

#!/usr/bin/perl -l

use warnings;

if (0
or 0 * $foo
or 0 * $bar
or 1) { $_="ok" }
__END__
Output​:
Name "main​::bar" used only once​: possible typo at a.pl line 8.
Name "main​::foo" used only once​: possible typo at a.pl line 7.
Use of uninitialized value $foo in multiplication (*) at a.pl line
5.
Use of uninitialized value $bar in multiplication (*) at a.pl line
5.

Where one might expect​:
Name "main​::bar" used only once​: possible typo at a.pl line 8.
Name "main​::foo" used only once​: possible typo at a.pl line 7.
Use of uninitialized value $foo in multiplication (*) at a.pl line
7.
Use of uninitialized value $bar in multiplication (*) at a.pl line
8.

Won't fix. Only control ops store file names and line numbers, not
every op, for space efficiency. So the first line of the expression is
reported.

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'rejected'

@p5pRT p5pRT closed this as completed Apr 28, 2008
toddr pushed a commit to toddr/perl that referenced this issue Sep 3, 2020
toddr pushed a commit to toddr/perl that referenced this issue Sep 3, 2020
Relates: Perl#226

When testing Devel-Peek we can run some tests
inside an eval and do not bother to check if it
succeeds or not.

As STDERR is redirected to a file, we do not even
notice the error message when this occurs.

This commit postpone the redirection of STDERR
and die if the eval quoted string from `do_test` fails.
toddr pushed a commit to toddr/perl that referenced this issue Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant