In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/f71d6157c7933c0d3df645f0411d97d7e2b66b2f?hp=0409250f9c9eac87ff80d18e21856800e91763b5>

- Log -----------------------------------------------------------------
commit f71d6157c7933c0d3df645f0411d97d7e2b66b2f
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Tue Jul 28 09:47:24 2009 +0200

    Forbid labels with keyword names
-----------------------------------------------------------------------

Summary of changes:
 pod/perl5110delta.pod |   12 ++++++++++++
 pod/perltodo.pod      |    9 ---------
 t/comp/colon.t        |    6 +++---
 toke.c                |    6 +++---
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/pod/perl5110delta.pod b/pod/perl5110delta.pod
index d7eb6dc..82d11e4 100644
--- a/pod/perl5110delta.pod
+++ b/pod/perl5110delta.pod
@@ -114,6 +114,18 @@ to avoid relying on the object's underlying structure). 
(However, if the
 object overloads the stringification or the numification operators, and
 if overload fallback is active, it will be used instead, as usual.)
 
+=head2 Labels can't be keywords
+
+Labels used as targets for the C<goto>, C<last>, C<next> or C<redo>
+statements cannot be keywords anymore. This restriction will prevent
+potential confusion between the C<goto LABEL> and C<goto EXPR> syntaxes:
+for example, a statement like C<goto print> would jump to a label whose
+name would be the return value of print(), (usually 1), instead of a
+label named C<print>. Moreover, the other control flow statements
+would just ignore any keyword passed to them as a label name. Since
+such labels cannot be defined anymore, this kind of error will be
+avoided.
+
 =head1 Core Enhancements
 
 =head2 The C<overloading> pragma
diff --git a/pod/perltodo.pod b/pod/perltodo.pod
index ba0462e..7b10f5f 100644
--- a/pod/perltodo.pod
+++ b/pod/perltodo.pod
@@ -804,15 +804,6 @@ also the warning messages (see L<perllexwarn>, 
C<warnings.pl>).
 These tasks would need C knowledge, and knowledge of how the interpreter works,
 or a willingness to learn.
 
-=head2 forbid labels with keyword names
-
-Currently C<goto keyword> "computes" the label value:
-
-    $ perl -e 'goto print'
-    Can't find label 1 at -e line 1.
-
-It would be nice to forbid labels with keyword names, to avoid confusion.
-
 =head2 truncate() prototype
 
 The prototype of truncate() is currently C<$$>. It should probably
diff --git a/t/comp/colon.t b/t/comp/colon.t
index d2c64fe..122e33e 100644
--- a/t/comp/colon.t
+++ b/t/comp/colon.t
@@ -125,14 +125,14 @@ ok 22, (not eval "y:1" and
        not eval "y:echo: eq y|echo|" and
        eval "y:echo:ohce: >= 0");
 
-ok 23, (eval "AUTOLOAD:1" and
+ok 23, (not eval "AUTOLOAD:1" and
        not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
        not eval "AUTOLOAD:echo:ohce: >= 0");
 
-ok 24, (eval "and:1" and
+ok 24, (not eval "and:1" and
        not eval "and:echo: eq and|echo|" and
        not eval "and:echo:ohce: >= 0");
 
-ok 25, (eval "alarm:1" and
+ok 25, (not eval "alarm:1" and
        not eval "alarm:echo: eq alarm|echo|" and
        not eval "alarm:echo:ohce: >= 0");
diff --git a/toke.c b/toke.c
index 658d163..554975a 100644
--- a/toke.c
+++ b/toke.c
@@ -5275,6 +5275,9 @@ 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) != ':') {
@@ -5284,9 +5287,6 @@ Perl_yylex(pTHX)
            TOKEN(LABEL);
        }
 
-       /* Check for keywords */
-       tmp = keyword(PL_tokenbuf, len, 0);
-
        /* Is this a word before a => operator? */
        if (*d == '=' && d[1] == '>') {
            CLINE;

--
Perl5 Master Repository

Reply via email to