summaryrefslogtreecommitdiff
path: root/t
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 /t
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 't')
-rw-r--r--t/comp/proto.t27
1 files changed, 26 insertions, 1 deletions
diff --git a/t/comp/proto.t b/t/comp/proto.t
index 734a68bdfc..e785a9bdd6 100644
--- a/t/comp/proto.t
+++ b/t/comp/proto.t
@@ -18,7 +18,7 @@ BEGIN {
# strict
use strict;
-print "1..153\n";
+print "1..160\n";
my $i = 1;
@@ -651,3 +651,28 @@ print "ok ", $i++, "\n";
eval 'sub bug (\[%@]) { } my $array = [0 .. 1]; bug %$array;';
print "not " unless $@ =~ /Not a HASH reference/;
print "ok ", $i++, "\n";
+
+# [perl #75904]
+# Test that the following prototypes make subs parse as unary functions:
+# * \sigil \[...] ;$ ;* ;\sigil ;\[...]
+print "not "
+ unless eval 'sub uniproto1 (*) {} uniproto1 $_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto2 (\$) {} uniproto2 $_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto3 (\[$%]) {} uniproto3 %_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto4 (;$) {} uniproto4 $_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto5 (;*) {} uniproto5 $_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto6 (;\@) {} uniproto6 @_, 1' or warn $@;
+print "ok ", $i++, "\n";
+print "not "
+ unless eval 'sub uniproto7 (;\[$%@]) {} uniproto7 @_, 1' or warn $@;
+print "ok ", $i++, "\n";