From: Rafael Garcia-Suarez Date: Thu, 19 Oct 2006 10:26:54 +0000 (+0000) Subject: Allow the _ prototype character to be followed by optional arguments X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb40c25d04faeb4e704ac10e016eece055ac741f;p=p5sagit%2Fp5-mst-13.2.git Allow the _ prototype character to be followed by optional arguments p4raw-id: //depot/perl@29048 --- diff --git a/op.c b/op.c index 95fb100..3dad488 100644 --- 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++; diff --git a/t/comp/uproto.t b/t/comp/uproto.t index 87c8be5..3da64d4 100644 --- a/t/comp/uproto.t +++ b/t/comp/uproto.t @@ -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;