summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-23 23:14:17 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-06-24 08:19:27 -0700
commit062678b2241d3d1cc3a46f80f402cf4147b825f1 (patch)
tree869c6c549fac533a09cf512a92680e2034916dfe /t
parentf5d552b480dda142e3e1fc3a463194ebdf0b8b3e (diff)
downloadperl-062678b2241d3d1cc3a46f80f402cf4147b825f1.tar.gz
Allow the \$ proto to accept any scalar lvalue [perl #91846]
This makes the \$ prototype’s parsing the same as the second argument to read(), making it possible to create a custom myread() function that has the same syntax. This is handled in two places in the prototype-parsing code, to avoid calling scalar() on the op if another character in \[...] will accept it. I don’t know what the consequences of that would be. So it calls Perl_op_lvalue_flags in the $ case only if it is not inside brackets. Then in the ] case it checks to see whether there was a $. OP_READ, not OP_ENTERSUB, is passed as the type to Perl_op_lvalue_flags, since OP_ENTERSUB would allow sub foo(\$) to accept an array as an argument. OP_RECV and OP_SYSREAD would have worked, too.
Diffstat (limited to 't')
-rw-r--r--t/comp/proto.t7
1 files changed, 6 insertions, 1 deletions
diff --git a/t/comp/proto.t b/t/comp/proto.t
index a982f6aff2..50aebef875 100644
--- a/t/comp/proto.t
+++ b/t/comp/proto.t
@@ -18,7 +18,7 @@ BEGIN {
# strict
use strict;
-print "1..171\n";
+print "1..174\n";
my $i = 1;
@@ -545,6 +545,9 @@ sub sreftest (\$$) {
sreftest($helem{$i}, $i++);
sreftest $aelem[0], $i++;
sreftest sub { [0] }->()[0], $i++;
+ sreftest my $a = 'quidgley', $i++;
+ print "not " if eval 'return 1; sreftest(3+4)';
+ print "ok ", $i++, ' - \$ with invalid argument', "\n";
}
# test single term
@@ -599,6 +602,8 @@ for my $p ( "", qw{ () ($) ($@) ($%) ($;$) (&) (&\@) (&@) (%) (\%) (\@) } ) {
print "not " unless myref($myvar) =~ /^SCALAR\(/;
print "ok ", $i++, "\n";
+ print "not " unless myref($myvar=7) =~ /^SCALAR\(/;
+ print "ok ", $i++, "\n";
print "not " unless myref(@myarray) =~ /^ARRAY\(/;
print "ok ", $i++, "\n";
print "not " unless myref(%myhash) =~ /^HASH\(/;