diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-08-11 11:53:08 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-08-11 11:53:08 +0200 |
commit | 649d02de73e8b1b9c262cff3c412f942cc4e7bdd (patch) | |
tree | 1c93a6132ad6aafa7563bd19aa0b68022f304ffd /toke.c | |
parent | beae72eec1a5f0babdb94514be158b0d599d674a (diff) | |
download | perl-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.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -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__"); |