The _ character is only allowed to be at the end of prototypes
Rafael Garcia-Suarez [Wed, 18 Oct 2006 14:01:59 +0000 (14:01 +0000)]
p4raw-id: //depot/perl@29036

op.c
t/comp/uproto.t

diff --git a/op.c b/op.c
index eb14e03..95fb100 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7376,6 +7376,9 @@ Perl_ck_subr(pTHX_ OP *o)
                proto++;
                continue;
            case '_':
+               /* _ must be at the end */
+               if (proto[1])
+                   goto oops;
            case '$':
                proto++;
                arg++;
index 16c748a..d09461f 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require "./test.pl";
 }
 
-plan(tests => 28);
+plan(tests => 30);
 
 sub f($$_) { my $x = shift; is("@_", $x) }
 
@@ -57,3 +57,9 @@ $_ = $expected;
 g();
 undef $expected; &g; # $_ not passed
 { $expected = my $_ = "bar"; g() }
+
+eval q{ sub wrong1 (_$); wrong1(1,2) };
+like( $@, qr/Malformed prototype for main::wrong1/, 'wrong1' );
+
+eval q{ sub wrong2 ($__); wrong2(1,2) };
+like( $@, qr/Malformed prototype for main::wrong2/, 'wrong2' );