This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow the _ prototype character to be followed by optional arguments
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 19 Oct 2006 10:26:54 +0000 (10:26 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 19 Oct 2006 10:26:54 +0000 (10:26 +0000)
p4raw-id: //depot/perl@29048

op.c
t/comp/uproto.t

diff --git a/op.c b/op.c
index 95fb100..3dad488 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7377,7 +7377,7 @@ Perl_ck_subr(pTHX_ OP *o)
                continue;
            case '_':
                /* _ must be at the end */
-               if (proto[1])
+               if (proto[1] && proto[1] != ';')
                    goto oops;
            case '$':
                proto++;
index 87c8be5..3da64d4 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require "./test.pl";
 }
 
-plan(tests => 33);
+plan(tests => 36);
 
 sub f($$_) { my $x = shift; is("@_", $x) }
 
@@ -67,5 +67,10 @@ like( $@, qr/Malformed prototype for main::wrong2/, 'wrong2' );
 sub opt ($;_) { is($_[0], "seen"); ok(!defined $_[1], "; has precedence over _") }
 opt("seen");
 
-sub unop (_) { is($_[0],11) }
+sub unop (_) { is($_[0], 11, "unary op") }
 unop 11, 22; # takes only the first parameter into account
+
+sub mymkdir (_;$) { is("@_", $expected, "mymkdir") }
+$expected = $_ = "mydir"; mymkdir();
+mymkdir($expected = "foo");
+$expected = "foo 493"; mymkdir foo => 0755;