From: Jan Dubois Date: Wed, 3 Mar 2010 00:24:23 +0000 (-0800) Subject: Revert "Forbid labels with keyword names" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=10517af500e340b88209d95ddbb26f6252464272;p=p5sagit%2Fp5-mst-13.2.git Revert "Forbid labels with keyword names" This reverts commit f71d6157c7933c0d3df645f0411d97d7e2b66b2f. Revert "Add new error "Can't use keyword '%s' as a label"" This reverts commit 28ccebc469d90664106fcc1cb73d7321c4b60716. --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index fbbf907..f0695ea 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -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 or C, -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/pod/perltodo.pod b/pod/perltodo.pod index 56d5045..d9d0807 100644 --- a/pod/perltodo.pod +++ b/pod/perltodo.pod @@ -920,6 +920,15 @@ also the warning messages (see L, C). 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 "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 91b2e36..e43af3b 100644 --- a/t/comp/colon.t +++ b/t/comp/colon.t @@ -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 --- 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;