In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/9dcb836830f7b4b182872b1181fb344b559c1d2e?hp=f3ce8053656a98bd26491b7d3bd1ab8d4b1aa855>
- Log ----------------------------------------------------------------- commit 9dcb836830f7b4b182872b1181fb344b559c1d2e Author: Father Chrysostomos <[email protected]> Date: Sat Jun 11 14:44:32 2011 -0700 [perl #90130] Allow CORE::* without feature.pm This commit allows feature.pm-enabled keywords to work with CORE::* even outside the scope of âuse featureâ. M pod/perldelta.pod M t/io/say.t M t/op/state.t M t/op/switch.t M toke.c commit a632cb9b5a97778e7d28500aa7b4ad50ddad8d36 Author: Father Chrysostomos <[email protected]> Date: Sat Jun 11 14:11:35 2011 -0700 Correct file references in switch.t M t/op/switch.t ----------------------------------------------------------------------- Summary of changes: pod/perldelta.pod | 5 +++++ t/io/say.t | 7 ++++++- t/op/state.t | 8 +++++++- t/op/switch.t | 14 +++++++++++--- toke.c | 11 +++++++---- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 7536cae..b983ed3 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -33,6 +33,11 @@ here, but most should go in the L</Performance Enhancements> section. [ List each enhancement as a =head2 entry ] +=head2 C<CORE::> works on all keywords + +The C<CORE::> prefix can now be used on keywords enabled by +L<feature.pm|feature>, even outside the scope of C<use feature>. + =head1 Security XXX Any security-related notices go here. In particular, any security diff --git a/t/io/say.t b/t/io/say.t index ead4d0b..70f83a7 100644 --- a/t/io/say.t +++ b/t/io/say.t @@ -16,7 +16,7 @@ BEGIN { use strict 'vars'; use feature "say"; -say "1..12"; +say "1..13"; my $foo = 'STDOUT'; say $foo "ok 1"; @@ -53,3 +53,8 @@ say STDOUT; local $, = "\nnot ok 13"; # how to fool Test::Harness say "ok 12"; } + +{ + no feature 'say'; + CORE::say "ok 13 - CORE::say without feature.pm"; +} diff --git a/t/op/state.t b/t/op/state.t index 611dd45..65f368b 100644 --- a/t/op/state.t +++ b/t/op/state.t @@ -8,9 +8,15 @@ BEGIN { } use strict; + +plan tests => 131; + +# Before loading feature.pm, test it with CORE:: +ok eval 'CORE::state $x = 1;', 'CORE::state outside of feature.pm scope'; + + use feature ":5.10"; -plan tests => 130; ok( ! defined state $uninit, q(state vars are undef by default) ); diff --git a/t/op/switch.t b/t/op/switch.t index 109bc2d..bb7569d 100644 --- a/t/op/switch.t +++ b/t/op/switch.t @@ -9,12 +9,20 @@ BEGIN { use strict; use warnings; -plan tests => 166; +plan tests => 168; -# The behaviour of the feature pragma should be tested by lib/switch.t -# using the tests in t/lib/switch/*. This file tests the behaviour of +# The behaviour of the feature pragma should be tested by lib/feature.t +# using the tests in t/lib/feature/*. This file tests the behaviour of # the switch ops themselves. + +# Before loading feature, test the switch ops with CORE:: +CORE::given(3) { + CORE::when(3) { pass "CORE::given and CORE::when"; CORE::continue } + CORE::default { pass "CORE::continue and CORE::default" } +} + + use feature 'switch'; eval { continue }; diff --git a/toke.c b/toke.c index 4860bd5..1e4beee 100644 --- a/toke.c +++ b/toke.c @@ -7055,11 +7055,12 @@ Perl_yylex(pTHX) s += 2; d = s; s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len); - if (!(tmp = keyword(PL_tokenbuf, len, 0))) + if (!(tmp = keyword(PL_tokenbuf, len, 1))) Perl_croak(aTHX_ "CORE::%s is not a keyword", PL_tokenbuf); if (tmp < 0) tmp = -tmp; - else if (tmp == KEY_require || tmp == KEY_do) + if (tmp == KEY_require || tmp == KEY_do || + tmp == KEY_continue) /* that's a way to remember we saw "CORE::" */ orig_keyword = tmp; goto reserved_word; @@ -7099,10 +7100,12 @@ Perl_yylex(pTHX) UNI(OP_CHOP); case KEY_continue: - /* When 'use switch' is in effect, continue has a dual + /* When 'use switch' is in effect or when + prefixed with CORE::, continue has a dual life as a control operator. */ { - if (!FEATURE_IS_ENABLED("switch")) + if ( !FEATURE_IS_ENABLED("switch") + && orig_keyword != KEY_continue ) PREBLOCK(CONTINUE); else { /* We have to disambiguate the two senses of -- Perl5 Master Repository
