summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-07-30 23:19:13 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-07-30 23:19:13 +0200
commit28ccebc469d90664106fcc1cb73d7321c4b60716 (patch)
treeb7b7698a545a537ffdff256440c9aa5c5f1a6daf /toke.c
parent8cf77941f2751a20a52ac4bbbcff354f82ac4c91 (diff)
downloadperl-28ccebc469d90664106fcc1cb73d7321c4b60716.tar.gz
Add new error "Can't use keyword '%s' as a label"
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/toke.c b/toke.c
index 554975a661..b264279a74 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] == '>') {