From: Nicholas Clark Date: Sat, 8 Sep 2007 21:47:24 +0000 (+0000) Subject: Make 'state $$' etc report 'Can't use global $$ in "state"' (not "my") X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aab6a793686b4f073e16b436e1705cd0e9106ced;p=p5sagit%2Fp5-mst-13.2.git Make 'state $$' etc report 'Can't use global $$ in "state"' (not "my") p4raw-id: //depot/perl@31823 --- diff --git a/op.c b/op.c index 4cbb5e6..6975d83 100644 --- a/op.c +++ b/op.c @@ -363,10 +363,12 @@ Perl_allocmy(pTHX_ const char *const name) { /* name[2] is true if strlen(name) > 2 */ if (!isPRINT(name[1]) || strchr("\t\n\r\f", name[1])) { - yyerror(Perl_form(aTHX_ "Can't use global %c^%c%s in \"my\"", - name[0], toCTRL(name[1]), name + 2)); + yyerror(Perl_form(aTHX_ "Can't use global %c^%c%s in \"%s\"", + name[0], toCTRL(name[1]), name + 2, + PL_parser->in_my == KEY_state ? "state" : "my")); } else { - yyerror(Perl_form(aTHX_ "Can't use global %s in \"my\"",name)); + yyerror(Perl_form(aTHX_ "Can't use global %s in \"%s\"",name, + PL_parser->in_my == KEY_state ? "state" : "my")); } } diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 05de058..cd741ab 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1133,7 +1133,7 @@ allowed. See L. (F) Only a simple scalar variable may be used as a loop variable on a foreach. -=item Can't use global %s in "my" +=item Can't use global %s in "%s" (F) You tried to declare a magical variable as a lexical variable. This is not allowed, because the magic can be tied to only one location