summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-08-11 11:53:08 +0200
committerRafael Garcia-Suarez <rgs@consttype.org>2010-08-11 11:53:08 +0200
commit649d02de73e8b1b9c262cff3c412f942cc4e7bdd (patch)
tree1c93a6132ad6aafa7563bd19aa0b68022f304ffd /toke.c
parentbeae72eec1a5f0babdb94514be158b0d599d674a (diff)
downloadperl-649d02de73e8b1b9c262cff3c412f942cc4e7bdd.tar.gz
[perl #75904] \$ prototype does not make a unary function
This fixes this problem : $ perl -le' sub foo($) { print "foo" }; foo $_, exit' foo $ perl -le' sub foo(\$) { print "foo" }; foo $_, exit' Too many arguments for main::foo at -e line 1, at EOF Execution of -e aborted due to compilation errors. for all those prototypes: * \sigil \[...] ;$ ;* ;\sigil ;\[...]
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 455f977c01..544cd1a754 100644
--- a/toke.c
+++ b/toke.c
@@ -6495,10 +6495,27 @@ Perl_yylex(pTHX)
const char *proto = SvPV_const(MUTABLE_SV(cv), protolen);
if (!protolen)
TERM(FUNC0SUB);
- if ((*proto == '$' || *proto == '_') && proto[1] == '\0')
- OPERATOR(UNIOPSUB);
while (*proto == ';')
proto++;
+ if (
+ (
+ (
+ *proto == '$' || *proto == '_'
+ || *proto == '*'
+ )
+ && proto[1] == '\0'
+ )
+ || (
+ *proto == '\\' && proto[1] && proto[2] == '\0'
+ )
+ )
+ OPERATOR(UNIOPSUB);
+ if (*proto == '\\' && proto[1] == '[') {
+ const char *p = proto + 2;
+ while(*p && *p != ']')
+ ++p;
+ if(*p == ']' && !p[1]) OPERATOR(UNIOPSUB);
+ }
if (*proto == '&' && *s == '{') {
if (PL_curstash)
sv_setpvs(PL_subname, "__ANON__");