summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldelta.pod7
-rw-r--r--pod/perldiag.pod2
-rw-r--r--pod/perlsub.pod7
-rwxr-xr-xt/comp/proto.t1
-rw-r--r--toke.c8
5 files changed, 20 insertions, 5 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 0ae001b51d..2ef1f418a6 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -224,6 +224,13 @@ The tr///C and tr///U features have been removed and will not return;
the interface was a mistake. Sorry about that. For similar
functionality, see pack('U0', ...) and pack('C0', ...).
+=item *
+
+Earlier Perls treated "sub foo (@bar)" as equivalent to "sub foo (@)".
+The prototypes are now checked at compile-time for invalid characters.
+An optional warning is generated ("Illegal character in prototype...")
+but this may be upgraded to a fatal error in a future release.
+
=back
=head1 Core Enhancements
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 29358eacac..777b0dd80a 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1612,7 +1612,7 @@ to your Perl administrator.
=item Illegal character in prototype for %s : %s
-(S) An illegal character was found in a prototype declaration. Legal
+(W syntax) An illegal character was found in a prototype declaration. Legal
characters in prototypes are $, @, %, *, ;, [, ], &, and \.
=item Illegal division by zero
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index aa5fd5b2cf..a1bba6eb31 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -1021,6 +1021,13 @@ programmers, and that it will not intrude greatly upon the meat of the
module, nor make it harder to read. The line noise is visually
encapsulated into a small pill that's easy to swallow.
+If you try to use an alphanumeric sequence in a prototype you will
+generate an optional warning - "Illegal character in prototype...".
+Unfortunately earlier versions of Perl allowed the prototype to be
+used as long as its prefix was a valid prototype. The warning may be
+upgraded to a fatal error in a future version of Perl once the
+majority of offending code is fixed.
+
It's probably best to prototype new functions, not retrofit prototyping
into older ones. That's because you must be especially careful about
silent impositions of differing list versus scalar contexts. For example,
diff --git a/t/comp/proto.t b/t/comp/proto.t
index 4141f2abc6..e020be7536 100755
--- a/t/comp/proto.t
+++ b/t/comp/proto.t
@@ -547,6 +547,7 @@ print "ok ", $i++, "\n";
# check that obviously bad prototypes are getting warnings
{
+ use warnings 'syntax';
my $warn = "";
local $SIG{__WARN__} = sub { $warn .= join("",@_) };
diff --git a/toke.c b/toke.c
index 6f06daa87f..3046bb535c 100644
--- a/toke.c
+++ b/toke.c
@@ -4968,10 +4968,10 @@ Perl_yylex(pTHX)
}
}
d[tmp] = '\0';
- if (bad_proto)
- Perl_warn(aTHX_
- "Illegal character in prototype for %s : %s",
- SvPVX(PL_subname), d);
+ if (bad_proto && ckWARN(WARN_SYNTAX))
+ Perl_warner(aTHX_ WARN_SYNTAX,
+ "Illegal character in prototype for %s : %s",
+ SvPVX(PL_subname), d);
SvCUR(PL_lex_stuff) = tmp;
have_proto = TRUE;