From: Rafael Garcia-Suarez Date: Thu, 30 Jul 2009 21:19:13 +0000 (+0200) Subject: Add new error "Can't use keyword '%s' as a label" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28ccebc469d90664106fcc1cb73d7321c4b60716;p=p5sagit%2Fp5-mst-13.2.git Add new error "Can't use keyword '%s' as a label" --- 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 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/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] == '>') {