Skip to content

Commit 849f151

Browse files
committed
deprecate the ':all' feature bundle
As discussed in Perl/PPCs#60, `:all` is very unlikely to be useful. Since it will enable all features a future Perl might support, it will also enable some that might be incompatible with the code as written (see `bitwise`, for example, which changes the meaning of the existing bitwise operators). With the addition of "negative" features in v5.32, `:all` became even less useful, since it would re-enable features deemed undesirable in modern Perl. As this point in time, `:all` is effectively a footgun. If the keyword `all` (from PPC0027) is added as a feature, there's an extra risk of confusion between `use feature 'all'` and `use feature ':all'`. This patch makes `:all` warn. We should consider removing that bundle entirely in the future.
1 parent 30a8f95 commit 849f151

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

lib/feature.pm

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pod/perldelta.pod

+6
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ L<XXX> has been upgraded from version A.xx to B.yy.
167167

168168
XXX If there was something important to note about this change, include that here.
169169

170+
=item *
171+
172+
L<feature> has been upgraded from version 1.89 to 1.93.
173+
174+
The C<:all> feature bundle now warns, suggesting you should not use it.
175+
170176
=back
171177

172178
=head2 Removed Modules and Pragmata

regen/feature.pl

+8-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ sub longest {
546546

547547
__END__
548548
package feature;
549-
our $VERSION = '1.92';
549+
our $VERSION = '1.93';
550550
551551
FEATURES
552552
@@ -1175,6 +1175,8 @@ sub __common {
11751175
my $name = shift;
11761176
if (substr($name, 0, 1) eq ":") {
11771177
my $v = substr($name, 1);
1178+
carp('Feature bundle ":all" is deprecated and should not be used')
1179+
if $v eq 'all';
11781180
if (!exists $feature_bundle{$v}) {
11791181
$v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
11801182
if (!exists $feature_bundle{$v}) {
@@ -1215,6 +1217,11 @@ sub unknown_feature_bundle {
12151217
$feature, $^V));
12161218
}
12171219
1220+
sub carp {
1221+
require Carp;
1222+
Carp::carp(@_);
1223+
}
1224+
12181225
sub croak {
12191226
require Carp;
12201227
Carp::croak(@_);

t/comp/require.t

-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ BEGIN {
368368
my @params = (
369369
'use v5.37',
370370
'use feature ":5.38"',
371-
'use feature ":all"',
372371
'use feature "module_true"',
373372
'no feature "module_true"',
374373
'',

t/lib/feature/bundle

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Assigning non-zero to $[ is no longer possible at - line 5.
100100
no feature ':all'; # turns array_base (and everything else) off
101101
$[ = 1;
102102
EXPECT
103+
Feature bundle ":all" is deprecated and should not be used at - line 2.
103104
Assigning non-zero to $[ is no longer possible at - line 3.
104105
########
105106
# NAME $^H accidentally enabling all features

t/op/lexsub.t

+3-3
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ like runperl(
442442
# This used to fail an assertion, but only as a standalone script
443443
is runperl(switches => ['-lXMfeature=:all'],
444444
prog => 'state sub x {}; undef &x; print defined &x',
445-
stderr => 1), "\n", 'undefining state sub';
445+
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n\n", 'undefining state sub';
446446
{
447447
state sub x { is +(caller 0)[3], 'x', 'state sub name in caller' }
448448
x
@@ -475,7 +475,7 @@ is runperl(switches => ['-lXMfeature=:all'],
475475
x()
476476
}
477477
x()',
478-
stderr => 1), "42\n",
478+
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n42\n",
479479
'closure behaviour of state sub in predeclared package sub';
480480

481481
# -------------------- my -------------------- #
@@ -830,7 +830,7 @@ pass "pad taking ownership once more of packagified my-sub";
830830
# This used to fail an assertion, but only as a standalone script
831831
is runperl(switches => ['-lXMfeature=:all'],
832832
prog => 'my sub x {}; undef &x; print defined &x',
833-
stderr => 1), "\n", 'undefining my sub';
833+
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n\n", 'undefining my sub';
834834
{
835835
my sub x { is +(caller 0)[3], 'x', 'my sub name in caller' }
836836
x

0 commit comments

Comments
 (0)