Navigation Menu

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

'no warnings' effects $@. #8957

Closed
p5pRT opened this issue Jul 4, 2007 · 7 comments
Closed

'no warnings' effects $@. #8957

p5pRT opened this issue Jul 4, 2007 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 4, 2007

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

Searchable as RT43545$

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 2007

From @Abigail

Created by @Abigail

It seem that sometimes that if one uses eval STRING, while warnings are
turned off, the warnings get prepended to $@​.

For instance​:

  $ perl -we 'eval "/ /a;"; print "[$@​]\n";'
  Bareword found where operator expected at (eval 1) line 1, near "/ /a"
  (Missing operator before a?)
  Unquoted string "a" may clash with future reserved word at (eval 1) line 1.
  [syntax error at (eval 1) line 1, near "/ /a"
  ]

The first three lines are (separate) warnings. The last line (syntax error...)
is what appears in $@​.

So far, so good. But now look what happens if we turn warnings off​:

  $ perl -Xe 'eval "/ /a;"; print "[$@​]\n";'
  [Bareword found where operator expected at (eval 1) line 1, near "/ /a"
  syntax error at (eval 1) line 1, near "/ /a"
  ]

No warnings get emitted, but the first warning (Bareword found...) is now
part of $@​.

This is certainly unexpected, and, IMO, a bug.

This happens in both maint and blead. And the same happens if one turns
off warnings using 'no warnings' instead of using -X.

"But you should always run with warnings on", someone is bound to say.
I always run with 'no warnings "syntax";' (because Perl way too often flags
correct syntax as being wrong) - and this particular case is effected by
'no warnings "syntax"'.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.8:

Configured by abigail at Fri Feb  3 23:37:31 CET 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.4.18-bf2.4, archname=i686-linux-64int-ld
    uname='linux alexandra 2.4.18-bf2.4 #1 son apr 14 09:53:28 cest 2002 i686 unknown '
    config_args='-des -Dusemorebits -Uversiononly -Dmydomain=.abigail.be -Dcf_email=abigail@abigail.be -Dperladmin=abigail@abigail.be -Doptimize=-g -Dcc=gcc -Dprefix=/opt/perl'
    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=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='3.0.4', 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='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    defined-or


@INC for perl v5.8.8:
    /home/abigail/Perl
    /opt/perl/lib/5.8.8/i686-linux-64int-ld
    /opt/perl/lib/5.8.8
    /opt/perl/lib/site_perl/5.8.8/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.8
    /opt/perl/lib/site_perl/5.8.7/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.7
    /opt/perl/lib/site_perl/5.8.6/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.6
    /opt/perl/lib/site_perl/5.8.5/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.5
    /opt/perl/lib/site_perl/5.8.4/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.4
    /opt/perl/lib/site_perl/5.8.3/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.3
    /opt/perl/lib/site_perl/5.8.2/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.2
    /opt/perl/lib/site_perl/5.8.1/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.1
    /opt/perl/lib/site_perl/5.8.0/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.8.0
    /opt/perl/lib/site_perl
    .


Environment for perl v5.8.8:
    HOME=/home/abigail
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/abigail/Bin:/opt/perl/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/usr/share/texmf/bin:/opt/Acrobat/bin:/opt/java/blackdown/j2sdk1.3.1/bin:/usr/local/games/bin
    PERL5LIB=/home/abigail/Perl
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

From rick@bort.ca

On Jul 04 2007, Abigail wrote​:

It seem that sometimes that if one uses eval STRING, while warnings are
turned off, the warnings get prepended to $@​.

Patch attached.

--
Rick Delaney
rick@​bort.ca

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

From rick@bort.ca

43545.patch
diff -pruN perl-current/t/op/eval.t perl-current-dev/t/op/eval.t
--- perl-current/t/op/eval.t	2006-11-02 12:39:26.000000000 -0500
+++ perl-current-dev/t/op/eval.t	2007-07-07 22:43:20.000000000 -0400
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-print "1..93\n";
+print "1..94\n";
 
 eval 'print "ok 1\n";';
 
@@ -455,6 +455,13 @@ print "ok $test - eval and last\n"; $tes
     local $@ = "foo";
     eval undef;
     print "not " unless $@ eq "";
-    print "ok $test # eval unef \n"; $test++;
+    print "ok $test # eval undef \n"; $test++;
+}
+
+{
+    no warnings;
+    eval "/ /a;";
+    print "not " unless $@ =~ /^syntax error/;
+    print "ok $test # eval syntax error, no warnings \n"; $test++;
 }
 
diff -pruN perl-current/toke.c perl-current-dev/toke.c
--- perl-current/toke.c	2007-07-07 04:10:45.000000000 -0400
+++ perl-current-dev/toke.c	2007-07-07 22:42:42.000000000 -0400
@@ -12540,8 +12540,10 @@ Perl_yyerror(pTHX_ const char *s)
                 (int)PL_multi_open,(int)PL_multi_close,(IV)PL_multi_start);
         PL_multi_end = 0;
     }
-    if (PL_in_eval & EVAL_WARNONLY && ckWARN_d(WARN_SYNTAX))
-	Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "%"SVf, SVfARG(msg));
+    if (PL_in_eval & EVAL_WARNONLY) {
+	if (ckWARN_d(WARN_SYNTAX))
+	    Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "%"SVf, SVfARG(msg));
+    }
     else
 	qerror(msg);
     if (PL_error_count >= 10) {

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2007

From @rgs

Good catch. Thanks, applied.

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2007

From [Unknown Contact. See original ticket]

Good catch. Thanks, applied.

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2007

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

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