This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop lexical warnings from turning off deprecations
authorFather Chrysostomos <sprout@cpan.org>
Fri, 14 Sep 2012 06:46:46 +0000 (23:46 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 15 Sep 2012 05:29:45 +0000 (22:29 -0700)
commit7fc874e826a059bd024f1cbd568e1021c5731f35
tree87c39161aa48a5e51e147ab2d5d8aabbd6abf775
parentf07626add3eda6dfda7c5f6fe05cbe1c9293ccd2
Stop lexical warnings from turning off deprecations

Some warnings, such as deprecation warnings, are on by default:

$ perl5.16.0 -e '$*'
$* is no longer supported at -e line 1.

But turning *on* other warnings will turn them off:

$ perl5.16.0 -e 'use warnings "void"; $*'
Useless use of a variable in void context at -e line 1.

Either all warnings in any given scope are controlled by lexical
hints, or none of them are.

When a single warnings category is turned on or off, if the warn-
ings were controlled by $^W, then all warnings are first turned on
lexically if $^W is 1 and all warnings are turned off lexically
if $^W is 0.

That has the unfortunate affect of turning off warnings when it was
only requested that warnings be turned on.

These categories contain default warnings:

ambiguous
debugging
deprecated
inplace
internal
io
malloc
utf8
redefine
syntax
glob
inplace
overflow
precedence
prototype
threads
misc

Most also contain regular warnings, but these contain *only*
default warnings:

debugging
deprecated
glob
inplace
malloc

So we can treat $^W==0 as equivalent to qw(debugging deprecated glob
inplace malloc) when enabling lexical warnings.

While this means that some default warnings will still be turned off
by ‘use warnings "void"’, it won’t be as many as before.  So at least
this is a step in the right direction.

(The real solution, of course, is to allow each warning to be turned
off or on on its own.)
dist/IO/t/IO.t
lib/warnings.pm
regen/warnings.pl
t/lib/warnings/2use
t/lib/warnings/regcomp
t/lib/warnings/toke
t/op/universal.t
t/uni/universal.t