Reserve the short named string operator names.
p4raw-id: //depot/perl@7941
eval "sub name { ... }";
}
+=item Subroutine name %s reserved for string operators
+
+(F) Certain string operators can be called with a very similar syntax
+to a function call, and therefore to avoid confusion their names are
+reserved and cannot be used as subroutine names. The reserved names
+are: C<m s tr y q qq qw qx qr>.
+
=item Substitution loop
(P) The substitution was looping infinitely. (Obviously, a substitution
print "$_ $s\n";
}
EXPECT
+########
+sub m {}
+EXPECT
+Subroutine name "m" reserved for string operators at - line 1.
if (isIDFIRST_lazy_if(s,UTF) || *s == '\'' ||
(*s == ':' && s[1] == ':'))
{
+ bool reserved = FALSE;
+
PL_expect = XBLOCK;
attrful = XATTRBLOCK;
/* remember buffer pos'n for later force_word */
}
s = skipspace(d);
have_name = TRUE;
+ switch (tmpbuf[0]) {
+ case 'm':
+ case 's':
+ case 'y':
+ if (tmpbuf[1] == 0)
+ reserved = TRUE;
+ break;
+ case 'q':
+ if (tmpbuf[1] == 0 ||
+ (strchr("qwxr", tmpbuf[1]) && tmpbuf[2] == 0))
+ reserved = TRUE;
+ break;
+ case 't':
+ if (tmpbuf[1] == 'r' && tmpbuf[2] == 0)
+ reserved = TRUE;
+ break;
+ default:
+ break;
+ }
+ if (reserved)
+ Perl_croak(aTHX_
+ "Subroutine name \"%s\" reserved for string operators",
+ tmpbuf);
}
else {
if (key == KEY_my)