This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "Forbid labels with keyword names"
authorJan Dubois <jand@activestate.com>
Wed, 3 Mar 2010 00:24:23 +0000 (16:24 -0800)
committerJan Dubois <jand@activestate.com>
Wed, 3 Mar 2010 06:24:37 +0000 (22:24 -0800)
This reverts commit f71d6157c7933c0d3df645f0411d97d7e2b66b2f.

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

This reverts commit 28ccebc469d90664106fcc1cb73d7321c4b60716.

pod/perldiag.pod
pod/perltodo.pod
t/comp/colon.t
toke.c

index fbbf907..f0695ea 100644 (file)
@@ -1159,11 +1159,6 @@ 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.
index 56d5045..d9d0807 100644 (file)
@@ -920,6 +920,15 @@ 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
index 91b2e36..e43af3b 100644 (file)
@@ -122,14 +122,14 @@ ok 22, (not eval "y:1" and
        not eval "y:echo: eq y|echo|" and
        eval "y:echo:ohce: >= 0");
 
-ok 23, (not eval "AUTOLOAD:1" and
+ok 23, (eval "AUTOLOAD:1" and
        not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
        not eval "AUTOLOAD:echo:ohce: >= 0");
 
-ok 24, (not eval "and:1" and
+ok 24, (eval "and:1" and
        not eval "and:echo: eq and|echo|" and
        not eval "and:echo:ohce: >= 0");
 
-ok 25, (not eval "alarm:1" and
+ok 25, (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 7167004..a7a71a4 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -6143,8 +6143,6 @@ Perl_yylex(pTHX)
        /* Is this a label? */
        if (!anydelim && PL_expect == XSTATE
              && d < PL_bufend && *d == ':' && *(d + 1) != ':') {
-           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;