From cb40c25d04faeb4e704ac10e016eece055ac741f Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Thu, 19 Oct 2006 10:26:54 +0000 Subject: [PATCH] Allow the _ prototype character to be followed by optional arguments p4raw-id: //depot/perl@29048 --- op.c | 2 +- t/comp/uproto.t | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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; -- 2.7.4