Change 14101 by ams@lustre on 2002/01/06 04:52:50

           Subject: [PATCH] Bad prototype detection now an optional warning
           From: Sam Tregar <[EMAIL PROTECTED]>
           Date: Sun, 6 Jan 2002 00:29:25 -0500 (EST)
           Message-Id: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/pod/perldelta.pod#280 edit
.... //depot/perl/pod/perldiag.pod#260 edit
.... //depot/perl/pod/perlsub.pod#40 edit
.... //depot/perl/t/comp/proto.t#35 edit
.... //depot/perl/toke.c#406 edit

Differences ...

==== //depot/perl/pod/perldelta.pod#280 (text) ====
Index: perl/pod/perldelta.pod
--- perl/pod/perldelta.pod.~1~  Sat Jan  5 22:00:05 2002
+++ perl/pod/perldelta.pod      Sat Jan  5 22:00:05 2002
@@ -224,6 +224,13 @@
 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

==== //depot/perl/pod/perldiag.pod#260 (text) ====
Index: perl/pod/perldiag.pod
--- perl/pod/perldiag.pod.~1~   Sat Jan  5 22:00:05 2002
+++ perl/pod/perldiag.pod       Sat Jan  5 22:00:05 2002
@@ -1612,7 +1612,7 @@
 
 =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

==== //depot/perl/pod/perlsub.pod#40 (text) ====
Index: perl/pod/perlsub.pod
--- perl/pod/perlsub.pod.~1~    Sat Jan  5 22:00:05 2002
+++ perl/pod/perlsub.pod        Sat Jan  5 22:00:05 2002
@@ -1021,6 +1021,13 @@
 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,

==== //depot/perl/t/comp/proto.t#35 (xtext) ====
Index: perl/t/comp/proto.t
--- perl/t/comp/proto.t.~1~     Sat Jan  5 22:00:05 2002
+++ perl/t/comp/proto.t Sat Jan  5 22:00:05 2002
@@ -547,6 +547,7 @@
 
 # check that obviously bad prototypes are getting warnings
 {
+  use warnings 'syntax';
   my $warn = "";
   local $SIG{__WARN__} = sub { $warn .= join("",@_) };
   

==== //depot/perl/toke.c#406 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~     Sat Jan  5 22:00:05 2002
+++ perl/toke.c Sat Jan  5 22:00:05 2002
@@ -4968,10 +4968,10 @@
                        }
                    }
                    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;
 
End of Patch.

Reply via email to