In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/28ccebc469d90664106fcc1cb73d7321c4b60716?hp=8cf77941f2751a20a52ac4bbbcff354f82ac4c91>

- Log -----------------------------------------------------------------
commit 28ccebc469d90664106fcc1cb73d7321c4b60716
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Thu Jul 30 23:19:13 2009 +0200

    Add new error "Can't use keyword '%s' as a label"
-----------------------------------------------------------------------

Summary of changes:
 pod/perldiag.pod |    5 +++++
 toke.c           |    9 ++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 2623010..9447ba4 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1147,6 +1147,11 @@ that is already inside a group with a byte-order 
modifier.
 For example you cannot force little-endianness on a type that
 is inside a big-endian group.
 
+=item Can't use keyword '%s' as a label
+
+(F) You attempted to use a reserved keyword, such as C<print> or C<BEGIN>,
+as a statement label. This is disallowed since Perl 5.11.0.
+
 =item Can't use "my %s" in sort comparison
 
 (F) The global variables $a and $b are reserved for sort comparisons.
diff --git a/toke.c b/toke.c
index 554975a..b264279 100644
--- a/toke.c
+++ b/toke.c
@@ -5275,17 +5275,20 @@ Perl_yylex(pTHX)
        while (d < PL_bufend && isSPACE(*d))
                d++;    /* no comments skipped here, or s### is misparsed */
 
-       /* Check for keywords */
-       tmp = keyword(PL_tokenbuf, len, 0);
-
        /* Is this a label? */
        if (!tmp && PL_expect == XSTATE
              && d < PL_bufend && *d == ':' && *(d + 1) != ':') {
+           tmp = keyword(PL_tokenbuf, len, 0);
+           if (tmp)
+               Perl_croak(aTHX_ "Can't use keyword '%s' as a label", 
PL_tokenbuf);
            s = d + 1;
            pl_yylval.pval = CopLABEL_alloc(PL_tokenbuf);
            CLINE;
            TOKEN(LABEL);
        }
+       else
+           /* Check for keywords */
+           tmp = keyword(PL_tokenbuf, len, 0);
 
        /* Is this a word before a => operator? */
        if (*d == '=' && d[1] == '>') {

--
Perl5 Master Repository

Reply via email to