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

Unsuppressable error/warning #7015

Closed
p5pRT opened this issue Jan 5, 2004 · 9 comments
Closed

Unsuppressable error/warning #7015

p5pRT opened this issue Jan 5, 2004 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 5, 2004

Migrated from rt.perl.org#24815 (status was 'resolved')

Searchable as RT24815$

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From perl-5.8.0@ton.iguana.be

Created by perl-5.8.0@ton.iguana.be

Normally I expect to be able to test a piece of perl code in an eval
without getting output (well, at least if I have warnings off, contrary
to what I do here)​:

perl -wle '$a="5 + "; eval $a; print "\$@​=$@​"'

Giving​:
$@​=syntax error at (eval 1) line 2, at EOF

However, some syntax errors lead to unsuppressable warnings​:

perl -wle '$a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
  (Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

It's not only the -w though. Even this doesn't suppress it​:

perl -Xle 'no warnings; $a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
  (Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

I can catch it using $SIG{__WARN__} though, so it really is a warning.
perl -wle '$SIG{__WARN__} = sub { }; $a="5 6"; eval $a; print "\$@​=$@​"'
$@​=syntax error at (eval 1) line 1, near "5 6"

But anyways, I think it shouldn't be a warning in the first place,
but just a plain error (as far as I know this message ALWAYS implies a
syntax error), and that the $@​ message is enough (though it possibly
could get the text of the warning added, or that text could replace
the $@​ error text).

If it is kept as a warning, I think it should obey $^W/no warnings/-X

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.2:

Configured by ton at Sun Jan  4 19:19:06 CET 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
  Platform:
    osname=linux, osvers=2.6.0, archname=i686-linux-64int-ld
    uname='linux quasar 2.6.0 #3 thu dec 18 18:22:48 cet 2003 i686 gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=define
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -fomit-frame-pointer',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.4.0 20031231 (experimental)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.2:
    /usr/lib/perl5/5.8.2/i686-linux-64int-ld
    /usr/lib/perl5/5.8.2
    /usr/lib/perl5/site_perl/5.8.2/i686-linux-64int-ld
    /usr/lib/perl5/site_perl/5.8.2
    /usr/lib/perl5/site_perl
    .


Environment for perl v5.8.2:
    HOME=/home/ton
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ton/bin.Linux:/home/ton/bin:/home/ton/bin.SampleSetup:/usr/local/bin:/usr/local/sbin:/usr/local/jre/bin:/home/oracle/product/9.0.1/bin:/usr/local/ar/bin:/usr/games/bin:/usr/X11R6/bin:/usr/share/bin:/usr/bin:/usr/sbin:/bin:/sbin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From @rgs

perl-5.8.0@​ton.iguana.be (via RT) wrote​:

However, some syntax errors lead to unsuppressable warnings​:

perl -wle '$a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

It's not only the -w though. Even this doesn't suppress it​:

perl -Xle 'no warnings; $a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

I turned it into a mandatory warning (change 22068), i.e. it's
on by default but "no warnings 'syntax'" silences it.

BTW the warning on "elseif" had the same problem.

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

@rgs - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jan 5, 2004
@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From @rgs

Rafael Garcia-Suarez wrote​:

perl-5.8.0@​ton.iguana.be (via RT) wrote​:

However, some syntax errors lead to unsuppressable warnings​:

perl -wle '$a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

It's not only the -w though. Even this doesn't suppress it​:

perl -Xle 'no warnings; $a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

I turned it into a mandatory warning (change 22068), i.e. it's
on by default but "no warnings 'syntax'" silences it.

and BTW note that this warning is actually a complement to an error :
when syntax warnings are disabled the message now goes into the error
message. See :

  $ ./perl -le 'eval"5 6";print "\$@​=<<$@​>>"'
  Number found where operator expected at (eval 1) line 1, near "5 6"
  (Missing operator before 6?)
  $@​=<<syntax error at (eval 1) line 1, near "5 6"
  >>

  $ ./perl -Xle 'eval"5 6";print "\$@​=<<$@​>>"'
  $@​=<<Number found where operator expected at (eval 1) line 1, near "5 6"
  syntax error at (eval 1) line 1, near "5 6"
  >>

BTW the warning on "elseif" had the same problem.

This one is really a warning. Using elseif as a bareword can be
perfectly legitimate :) now :

  $ ./perl -le 'print STDOUT elseif'
  elseif should be elsif at -e line 1.
  elseif
  $ ./perl -Xle 'print STDOUT elseif'
  elseif

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From perl5-porters@ton.iguana.be

In article <20040105232341.270ab0b2.rgarciasuarez@​_ree._r>,
  Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

Rafael Garcia-Suarez wrote​:

and BTW note that this warning is actually a complement to an error :
when syntax warnings are disabled the message now goes into the error
message. See :

$ \./perl \-le 'eval"5 6";print "\\$@&#8203;=\<\<$@&#8203;>>"'
Number found where operator expected at \(eval 1\) line 1\, near "5 6"
    \(Missing operator before  6?\)
$@&#8203;=\<\<syntax error at \(eval 1\) line 1\, near "5 6"
$ \./perl \-Xle 'eval"5 6";print "\\$@&#8203;=\<\<$@&#8203;>>"'
$@&#8203;=\<\<Number found where operator expected at \(eval 1\) line 1\, near "5 6"
syntax error at \(eval 1\) line 1\, near "5 6"

Great. Thanks for your amazingly quick solution.

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From perl5-porters@ton.iguana.be

In article <20040105231525.4b53eb1d.rgarciasuarez@​_ree._r>,
  Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

perl-5.8.0@​ton.iguana.be (via RT) wrote​:

However, some syntax errors lead to unsuppressable warnings​:

perl -wle '$a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

It's not only the -w though. Even this doesn't suppress it​:

perl -Xle 'no warnings; $a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

I turned it into a mandatory warning (change 22068), i.e. it's
on by default but "no warnings 'syntax'" silences it.

The basic problem is now solved for me. Good.
I am curious why you made it a mandatory warning though. Doesn't it
ALWAYS lead to a syntax error, so is there really any point in
bothering to warn before erroring out ?
What makes this deserve a mandatory warning more than errors like "5 +" ?

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From @rgs

Ton Hospel wrote​:

In article <20040105231525.4b53eb1d.rgarciasuarez@​_ree._r>,
Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

perl-5.8.0@​ton.iguana.be (via RT) wrote​:

However, some syntax errors lead to unsuppressable warnings​:

perl -wle '$a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

It's not only the -w though. Even this doesn't suppress it​:

perl -Xle 'no warnings; $a="5 6"; eval $a; print "\$@​=$@​"'
Number found where operator expected at (eval 1) line 1, near "5 6"
(Missing operator before 6?)
$@​=syntax error at (eval 1) line 1, near "5 6"

I turned it into a mandatory warning (change 22068), i.e. it's
on by default but "no warnings 'syntax'" silences it.

The basic problem is now solved for me. Good.
I am curious why you made it a mandatory warning though. Doesn't it
ALWAYS lead to a syntax error, so is there really any point in
bothering to warn before erroring out ?
What makes this deserve a mandatory warning more than errors like "5 +" ?

The warn() and the croak() are issued in different parts of the
tokenizer :) so the message is emitted in parts. You wouldn't want to
croak before the last part is printed.

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2004

From perl5-porters@ton.iguana.be

In article <20040106001110.544e6c76.rgarciasuarez@​_ree._r>,
  Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

The warn() and the croak() are issued in different parts of the
tokenizer :) so the message is emitted in parts. You wouldn't want to
croak before the last part is printed.

My first reaction was that you could make the warn() a croak() and
already add the the text of the croak() that's now not reached.
But I indeed see that you can miss later warnings that way, the
tokenizer still seems to make progress after that point​:

perl -wle '$a="5 6; 7 8"; eval $a'
Number found where operator expected at (eval 1) line 1, near "5 6"
  (Missing operator before 6?)
Number found where operator expected at (eval 1) line 1, near "7 8"
  (Missing operator before 8?)

Well, I'm surprised but at least I understand now :-)

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