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 "bareword" turns off too many warnings. #1995

Closed
p5pRT opened this issue May 19, 2000 · 15 comments
Closed

no warnings "bareword" turns off too many warnings. #1995

p5pRT opened this issue May 19, 2000 · 15 comments

Comments

@p5pRT
Copy link

p5pRT commented May 19, 2000

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

Searchable as RT3269$

@p5pRT
Copy link
Author

p5pRT commented May 19, 2000

From abigail@arenanetworks.com

Created by abigail@arena-i.com

  $ perl -wle 'foo.bar'
  Unquoted string "foo" may clash with future reserved word at -e line 1.
  Unquoted string "bar" may clash with future reserved word at -e line 1.
  Useless use of concatenation (.) in void context at -e line 1.
  $ perl -wle 'no warnings "bareword"; foo.bar'
  $

The latter should warn about the void use of concatenation.

  $ perl -wle 'use warnings "all"; no warnings "bareword"; foo.bar'
  Unquoted string "foo" may clash with future reserved word at -e line 1.
  Unquoted string "bar" may clash with future reserved word at -e line 1.
  Useless use of concatenation (.) in void context at -e line 1.
  $

And this should have warned only about the void use of concatenation.

Abigail

Perl Info

Flags:
    category=core
    severity=medium

This perlbug was built using Perl v5.6.0 - Thu Mar 23 19:51:19 EST 2000
It is being executed now by  Perl v5.6.0 - Fri Mar 24 17:24:48 EST 2000.

Site configuration information for perl v5.6.0:

Configured by abigail at Fri Mar 24 17:24:48 EST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=i86pc-solaris-64int
    uname='sunos newyork 5.7 generic_106542-07 i86pc i386 i86pc '
    config_args='-d -Dprefix=/opt/perl -Uinstallusrbinperl -Doptimize=-g -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.95.1 19990816 (release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/perl/lib/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/5.6.0
    /opt/perl/lib/site_perl/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/abigail/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/usr/ccs/bin:/usr/openwin/bin:/opt/Acrobat4/bin:/opt/cvs/bin:/opt/perl/bin
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2000

From [Unknown Contact. See original ticket]

Created by abigail@arena-i.com

  $ perl -wle 'foo.bar'
  Unquoted string "foo" may clash with future reserved word at -e line 1.
  Unquoted string "bar" may clash with future reserved word at -e line 1.
  Useless use of concatenation (.) in void context at -e line 1.
  $ perl -wle 'no warnings "bareword"; foo.bar'
  $

The latter should warn about the void use of concatenation.

  $ perl -wle 'use warnings "all"; no warnings "bareword"; foo.bar'
  Unquoted string "foo" may clash with future reserved word at -e line 1.
  Unquoted string "bar" may clash with future reserved word at -e line 1.
  Useless use of concatenation (.) in void context at -e line 1.
  $

And this should have warned only about the void use of concatenation.

Abigail

Perl Info

Flags:
    category=core
    severity=medium

This perlbug was built using Perl v5.6.0 - Thu Mar 23 19:51:19 EST 2000
It is being executed now by  Perl v5.6.0 - Fri Mar 24 17:24:48 EST 2000.

Site configuration information for perl v5.6.0:

Configured by abigail at Fri Mar 24 17:24:48 EST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=i86pc-solaris-64int
    uname='sunos newyork 5.7 generic_106542-07 i86pc i386 i86pc '
    config_args='-d -Dprefix=/opt/perl -Uinstallusrbinperl -Doptimize=-g
-Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.95.1 19990816 (release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/perl/lib/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/5.6.0
    /opt/perl/lib/site_perl/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
   
LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
   
PATH=/home/abigail/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/usr/ccs/bin:/usr/openwin/bin:/opt/Acrobat4/bin:/opt/cvs/bin:/opt/perl/bin
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @schwern

[abigail@​arenanetworks.com - Fri May 19 04​:23​:23 2000]​:

$ perl \-wle 'foo\.bar'
Unquoted string "foo" may clash with future reserved word at \-e

line 1.
Unquoted string "bar" may clash with future reserved word at -e
line 1.
Useless use of concatenation (.) in void context at -e line 1.
$ perl -wle 'no warnings "bareword"; foo.bar'
$

It seems that 'no warnings "foo"' without a preceding "use warnings"
turns off all warnings even if -w is given!

The latter should warn about the void use of concatenation.

$ perl \-wle 'use warnings "all"; no warnings "bareword"; foo\.bar'
Unquoted string "foo" may clash with future reserved word at \-e

line 1.
Unquoted string "bar" may clash with future reserved word at -e
line 1.
Useless use of concatenation (.) in void context at -e line 1.
$

And this should have warned only about the void use of concatenation.

No, "Unquoted string..." is a "reserved" warning.

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From rick@bort.ca

On Tue, Jul 12, 2005 at 08​:54​:18PM -0700, Michael G Schwern via RT wrote​:

[abigail@​arenanetworks.com - Fri May 19 04​:23​:23 2000]​:

$ perl \-wle 'foo\.bar'
Unquoted string "foo" may clash with future reserved word at \-e

line 1.
Unquoted string "bar" may clash with future reserved word at -e
line 1.
Useless use of concatenation (.) in void context at -e line 1.
$ perl -wle 'no warnings "bareword"; foo.bar'
$

It seems that 'no warnings "foo"' without a preceding "use warnings"
turns off all warnings even if -w is given!

This patch breaks test 37 of ext/B/t/deparse.t because this warning​:

# [Using a hash as a reference is deprecated at lib/B/Deparse.pm line 3151.

is no longer suppressed by C<no warnings 'uninitialized'>.

--
Rick Delaney
rick@​bort.ca

Inline Patch
diff -ruN perl-current/mg.c perl-current-dev/mg.c
--- perl-current/mg.c	2005-07-07 11:16:35.000000000 -0400
+++ perl-current-dev/mg.c	2005-07-13 03:37:46.973571403 -0400
@@ -781,11 +781,16 @@
 	if (*(mg->mg_ptr+1) == '\0')
 	    sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) ? TRUE : FALSE));
 	else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
-	    if (PL_compiling.cop_warnings == pWARN_NONE ||
-	        PL_compiling.cop_warnings == pWARN_STD)
-	    {
+	    if (PL_compiling.cop_warnings == pWARN_NONE) {
 	        sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
-            }
+	    }
+	    else if (PL_compiling.cop_warnings == pWARN_STD) {
+		sv_setpvn(
+		    sv, 
+		    (PL_dowarn & G_WARN_ON) ? WARN_ALLstring : WARN_NONEstring,
+		    WARNsize
+		);
+	    }
             else if (PL_compiling.cop_warnings == pWARN_ALL) {
 		/* Get the bit mask for $warnings::Bits{all}, because
 		 * it could have been extended by warnings::register */
diff -ruN perl-current/t/lib/warnings/2use perl-current-dev/t/lib/warnings/2use
--- perl-current/t/lib/warnings/2use	2004-04-23 17:05:07.000000000 -0400
+++ perl-current-dev/t/lib/warnings/2use	2005-07-13 03:27:32.832203077 -0400
@@ -72,6 +72,12 @@
 EXPECT
 Reversed += operator at - line 3.
 ########
+-w
+no warnings 'reserved' ;
+foo.bar;
+EXPECT
+Useless use of concatenation (.) or string in void context at - line 3.
+########
 
 --FILE-- abc
 my $a =+ 1 ;

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @schwern

On Wed, Jul 13, 2005 at 03​:48​:26AM -0400, Rick Delaney wrote​:

This patch breaks test 37 of ext/B/t/deparse.t because this warning​:

# [Using a hash as a reference is deprecated at lib/B/Deparse.pm line 3151.

is no longer suppressed by C<no warnings 'uninitialized'>.

I think this patch does the same thing without the deprecated syntax.

$ perl -wle '%hash = (foo => 42); print %{"hash"}->{foo}; print ${"hash"}{foo}'
Using a hash as a reference is deprecated at -e line 1.
Name "main​::hash" used only once​: possible typo at -e line 1.
42
42

I wonder what other accidentally supressed warnings this is going to
dig up.

--- ext/B/B/Deparse.pm 2005/07/13 22​:50​:34 1.1
+++ ext/B/B/Deparse.pm 2005/07/13 22​:55​:26
@​@​ -3148,7 +3148,7 @​@​
  no warnings 'uninitialized';
  $declared = exists $self->{'subs_declared'}{$kid}
  || (
- defined &{ %{$self->{'curstash'}."​::"}->{$kid} }
+ defined &{ ${$self->{'curstash'}."​::"}{$kid} }
  && !exists
  $self->{'subs_deparsed'}{$self->{'curstash'}."​::".$kid}
  && defined prototype $self->{'curstash'}."​::".$kid

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
Ahh email, my old friend. Do you know that revenge is a dish that is best
served cold? And it is very cold on the Internet!

@p5pRT
Copy link
Author

p5pRT commented Jul 14, 2005

From rick@bort.ca

On Wed, Jul 13, 2005 at 03​:57​:39PM -0700, Michael G Schwern wrote​:

I think this patch does the same thing without the deprecated syntax.

Thanks, that saves me doing it.

I wonder what other accidentally supressed warnings this is going to
dig up.

Not too many from `make test`. Just these​:

  t/op/inc..................................
  Parentheses missing around "my" list at op/inc.t line 163.
  Parentheses missing around "my" list at op/inc.t line 171.
  Useless use of a variable in void context at op/inc.t line 163.
  Useless use of a variable in void context at op/inc.t line 171.

Patch after .sig.

--
Rick Delaney
rick@​bort.ca

Inline Patch
diff -ruN perl-current/t/op/inc.t perl-current-dev/t/op/inc.t
--- perl-current/t/op/inc.t	2005-07-09 12:13:42.000000000 -0400
+++ perl-current-dev/t/op/inc.t	2005-07-13 20:17:39.315185314 -0400
@@ -160,7 +160,7 @@
 
 {
     no warnings 'uninitialized';
-    my $x, $y;
+    my ($x, $y);
     eval {
 	$y ="$x\n";
 	++$x;
@@ -168,7 +168,7 @@
     ok($x == 1, $x);
     ok($@ eq '', $@);
 
-    my $p, $q;
+    my ($p, $q);
     eval {
 	$q ="$p\n";
 	--$p;

@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2005

From @steve-m-hay

Michael G Schwern wrote​:

On Wed, Jul 13, 2005 at 03​:48​:26AM -0400, Rick Delaney wrote​:

This patch breaks test 37 of ext/B/t/deparse.t because this warning​:

# [Using a hash as a reference is deprecated at lib/B/Deparse.pm line 3151.

is no longer suppressed by C<no warnings 'uninitialized'>.

I think this patch does the same thing without the deprecated syntax.

Thanks. Applied as part of change 25153.


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2005

From @steve-m-hay

Rick Delaney wrote​:

I wonder what other accidentally supressed warnings this is going to
dig up.

Not too many from `make test`. Just these​:

t/op/inc..................................
Parentheses missing around "my" list at op/inc.t line 163.
Parentheses missing around "my" list at op/inc.t line 171.
Useless use of a variable in void context at op/inc.t line 163.
Useless use of a variable in void context at op/inc.t line 171.

Patch after .sig.

Thanks. Applied as part of change 25153.


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2005

From p5p@spam.wizbit.be

There is still an issue with the patch that I would like to address, mixing -w, $^W and 'no warnings' results in unexpected (or atleast unexpected to me) behaviour...

Example​:

#!perl -w

$^W = 0;
no warnings qw/numeric/;
my $b;
chop $b;

This results in a warning​: Use of uninitialized value $b in scalar chop...

Without the 'no warnings' it (obviously) doesn't warn.

Ofcourse noone would do this intentionally but it might occur when old code gets mixed with new code...

I wonder what other accidentally supressed warnings this is going to
dig up.

It doesn't really break it but it does produce a warning on test 9 of t/io/binmode.t​:

Name "main​::B" used only once​: possible typo at t/io/binmode.t line 40.

Patch​:

Inline Patch
--- old/t/io/binmode.t  2005-07-30 22:56:59.000000000 +0200
+++ new/t/io/binmode.t  2005-07-30 22:59:31.000000000 +0200
@@ -35,7 +35,7 @@
     skip "minitest", 1 if $ENV{PERL_CORE_MINITEST};
     skip "no EBADF", 1 if (!exists &Errno::EBADF);
 
-    no warnings 'io';
+    no warnings 'io', 'once';
     $! = 0;
     binmode(B);
     ok($! == &Errno::EBADF);

@p5pRT
Copy link
Author

p5pRT commented Sep 17, 2005

From rick@bort.ca

Does this patch look ok?

On Wed, Jul 13, 2005 at 03​:48​:26AM -0400, Rick Delaney wrote​:

diff -ruN perl-current/mg.c perl-current-dev/mg.c
--- perl-current/mg.c 2005-07-07 11​:16​:35.000000000 -0400
+++ perl-current-dev/mg.c 2005-07-13 03​:37​:46.973571403 -0400
@​@​ -781,11 +781,16 @​@​
if (*(mg->mg_ptr+1) == '\0')
sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) ? TRUE : FALSE));
else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
- if (PL_compiling.cop_warnings == pWARN_NONE ||
- PL_compiling.cop_warnings == pWARN_STD)
- {
+ if (PL_compiling.cop_warnings == pWARN_NONE) {
sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
- }
+ }
+ else if (PL_compiling.cop_warnings == pWARN_STD) {
+ sv_setpvn(
+ sv,
+ (PL_dowarn & G_WARN_ON) ? WARN_ALLstring : WARN_NONEstring,
+ WARNsize
+ );
+ }
else if (PL_compiling.cop_warnings == pWARN_ALL) {
/* Get the bit mask for $warnings​::Bits{all}, because
* it could have been extended by warnings​::register */
diff -ruN perl-current/t/lib/warnings/2use perl-current-dev/t/lib/warnings/2use
--- perl-current/t/lib/warnings/2use 2004-04-23 17​:05​:07.000000000 -0400
+++ perl-current-dev/t/lib/warnings/2use 2005-07-13 03​:27​:32.832203077 -0400
@​@​ -72,6 +72,12 @​@​
EXPECT
Reversed += operator at - line 3.
########
+-w
+no warnings 'reserved' ;
+foo.bar;
+EXPECT
+Useless use of concatenation (.) or string in void context at - line 3.
+########

--FILE-- abc
my $a =+ 1 ;

--
Rick Delaney
rick@​bort.ca

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2005

From guest@guest.guest.xxxxxxxx

Ping.

[rickdelaney - Sat Sep 17 08​:07​:20 2005]​:

Does this patch look ok?

  $self->talking_to("Why, yes it does!");

It would be nice if this could make it into 5.8.8.

--rick

On Wed, Jul 13, 2005 at 03​:48​:26AM -0400, Rick Delaney wrote​:

diff -ruN perl-current/mg.c perl-current-dev/mg.c
--- perl-current/mg.c 2005-07-07 11​:16​:35.000000000 -0400
+++ perl-current-dev/mg.c 2005-07-13 03​:37​:46.973571403 -0400
@​@​ -781,11 +781,16 @​@​
if (*(mg->mg_ptr+1) == '\0')
sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) ? TRUE : FALSE));
else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
- if (PL_compiling.cop_warnings == pWARN_NONE ||
- PL_compiling.cop_warnings == pWARN_STD)
- {
+ if (PL_compiling.cop_warnings == pWARN_NONE) {
sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
- }
+ }
+ else if (PL_compiling.cop_warnings == pWARN_STD) {
+ sv_setpvn(
+ sv,
+ (PL_dowarn & G_WARN_ON) ? WARN_ALLstring : WARN_NONEstring,
+ WARNsize
+ );
+ }
else if (PL_compiling.cop_warnings == pWARN_ALL) {
/* Get the bit mask for $warnings​::Bits{all}, because
* it could have been extended by warnings​::register */
diff -ruN perl-current/t/lib/warnings/2use perl-current-
dev/t/lib/warnings/2use
--- perl-current/t/lib/warnings/2use 2004-04-23 17​:05​:07.000000000
-0400
+++ perl-current-dev/t/lib/warnings/2use 2005-07-13
03​:27​:32.832203077 -0400
@​@​ -72,6 +72,12 @​@​
EXPECT
Reversed += operator at - line 3.
########
+-w
+no warnings 'reserved' ;
+foo.bar;
+EXPECT
+Useless use of concatenation (.) or string in void context at -
line 3.
+########

--FILE-- abc
my $a =+ 1 ;

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2005

From @rgs

Guest via RT wrote​:

Ping.

[rickdelaney - Sat Sep 17 08​:07​:20 2005]​:

Does this patch look ok?

$self->talking_to("Why, yes it does!");

It would be nice if this could make it into 5.8.8.

I applied it as change #25619 to bleadperl. For some reason it
had disappeared from my mailbox...

--
A First Encyclopedia of Tlön. Vol. XI. Hlaer to Jangr.
  -- Borges

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2005

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

@p5pRT p5pRT closed this as completed Sep 27, 2005
@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2005

From p5p@spam.wizbit.be

[rickdelaney - Sat Sep 17 08​:07​:20 2005]​:

Does this patch look ok?

The patch might be ok but something is still broken...

Below you find two examples​: one in which a warning should be produced and another one where no warning should be produced. It does the exact opposite of what I expect... even though ${^WARNING_BITS} seems to be correct... (So I'm not sure if this is an issue with this patch or with something else)

Example 1​:

#!perl

$^W = 1;
no warnings qw/numeric/;
my $b;
chop $b;

No -w, but $^W is 1 so it should produce the warning. (It produces one if 'no warnings' is left out.)

Example 2​:

#!perl -w

$^W = 0;
no warnings qw/numeric/;
my $b;
chop $b;

-w is set but $^W is 0 so warnings are disabled. So the warning shouldn't be shown...

My best guess is that those problems happen because the no warnings is done at compile time while $^W is changed at run time...

Another thing that might not work 100% is -W and/or -X... my basic testing shows that they work as expected but I only did some basic tests...

(I tried modifying the patch but without success.)

Can you be kind enough to take (another) look at it? :)

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2005

From rick@bort.ca

On Tue, Nov 29, 2005 at 03​:01​:43PM -0800, Animator via RT wrote​:

Below you find two examples​: one in which a warning should be produced and another one where no warning should be produced. It does the exact opposite of what I expect... even though ${^WARNING_BITS} seems to be correct... (So I'm not sure if this is an issue with this patch or with something else)

Example 1​:

#!perl

$^W = 1;
no warnings qw/numeric/;
my $b;
chop $b;

No -w, but $^W is 1 so it should produce the warning. (It produces one if 'no warnings' is left out.)

Example 2​:

#!perl -w

$^W = 0;
no warnings qw/numeric/;
my $b;
chop $b;

-w is set but $^W is 0 so warnings are disabled. So the warning shouldn't be shown...

My best guess is that those problems happen because the no warnings is done at compile time while $^W is changed at run time...

Right, so if you put the assignments to $^W in BEGIN blocks then things
should work as you expect. Warnings will be globally enabled/disabled
and numeric warnings will be disabled after the C<no warnings qw/numeric/>
statment.

The main thing to realize is that the statment

  no warnings qw/numeric/;

should disable only numeric warnings and no others. And since the
statement happens at compile time the other warnings that it should
leave enabled must be ones that were also enabled at compile time.
There are only 3 ways this can happen​:

  use warnings;
  -w
  BEGIN { $^W = 1 }

Another thing that might not work 100% is -W and/or -X... my basic testing shows that they work as expected but I only did some basic tests...

Well, if you do find something, feel free to submit a bug report.

Can you be kind enough to take (another) look at it? :)

Looks good to me. :-) But if you think a doc patch is required it
should probably go in perllexwarn.

HTH,

--
Rick Delaney
rick@​bort.ca

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