summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/feature.pm12
-rw-r--r--perl_keyword.pl2
-rw-r--r--t/op/state.t1
-rw-r--r--toke.c2
4 files changed, 13 insertions, 4 deletions
diff --git a/lib/feature.pm b/lib/feature.pm
index d4975e411e..240d46dc46 100644
--- a/lib/feature.pm
+++ b/lib/feature.pm
@@ -1,6 +1,6 @@
package feature;
-our $VERSION = '1.00';
+our $VERSION = '1.01';
# (feature name) => (internal name, used in %^H)
my %feature = (
@@ -8,10 +8,11 @@ my %feature = (
"~~" => "feature_~~",
say => "feature_say",
err => "feature_err",
+ state => "feature_state",
);
my %feature_bundle = (
- "5.10" => [qw(switch ~~ say err)],
+ "5.10" => [qw(switch ~~ say err state)],
);
@@ -81,13 +82,18 @@ operator from here to the end of the enclosing BLOCK.
C<err> is a low-precedence variant of the C<//> operator:
see C<perlop> for details.
+=head2 the 'state' feature
+
+C<use feature 'state'> tells the compiler to enable C<state>
+variables from here to the end of the enclosing BLOCK.
+
=head1 FEATURE BUNDLES
It's possible to load a whole slew of features in one go, using
a I<feature bundle>. The name of a feature bundle is prefixed with
a colon, to distinguish it from an actual feature. At present, the
only feature bundle is C<use feature ":5.10">, which is equivalent
-to C<use feature qw(switch ~~ say err)>.
+to C<use feature qw(switch ~~ say err state)>.
=cut
diff --git a/perl_keyword.pl b/perl_keyword.pl
index 636f6a9426..b2e9e3424c 100644
--- a/perl_keyword.pl
+++ b/perl_keyword.pl
@@ -45,6 +45,8 @@ my %feature_kw = (
say => 'say',
err => 'err',
+
+ state => 'state',
);
my %pos = map { ($_ => 1) } @pos;
diff --git a/t/op/state.t b/t/op/state.t
index 987cf6ec94..3b68879600 100644
--- a/t/op/state.t
+++ b/t/op/state.t
@@ -7,6 +7,7 @@ BEGIN {
}
use strict;
+use feature "state";
plan tests => 19;
diff --git a/toke.c b/toke.c
index 3700e342ba..23f801e352 100644
--- a/toke.c
+++ b/toke.c
@@ -8144,7 +8144,7 @@ Perl_keyword (pTHX_ const char *name, I32 len)
if (name[3] == 't' &&
name[4] == 'e')
{ /* state */
- return KEY_state;
+ return (FEATURE_IS_ENABLED("state") ? KEY_state : 0);
}
goto unknown;