From: Gurusamy Sarathy Date: Sat, 17 Jul 1999 19:12:33 +0000 (+0000) Subject: allow $foo{$x} and $bar[$i] for (\$) prototype X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c01eb51ee8cc1e95e1f674a8ad0766f5498744b;p=p5sagit%2Fp5-mst-13.2.git allow $foo{$x} and $bar[$i] for (\$) prototype p4raw-id: //depot/perl@3681 --- diff --git a/op.c b/op.c index ae6297c..b605e66 100644 --- a/op.c +++ b/op.c @@ -5548,6 +5548,8 @@ Perl_ck_subr(pTHX_ OP *o) case '$': if (o2->op_type != OP_RV2SV && o2->op_type != OP_PADSV + && o2->op_type != OP_HELEM + && o2->op_type != OP_AELEM && o2->op_type != OP_THREADSV) { bad_type(arg, "scalar", gv_ename(namegv), o2); diff --git a/t/comp/proto.t b/t/comp/proto.t index 6d60342..ecfbec6 100755 --- a/t/comp/proto.t +++ b/t/comp/proto.t @@ -16,7 +16,7 @@ BEGIN { use strict; -print "1..100\n"; +print "1..107\n"; my $i = 1; @@ -448,11 +448,21 @@ star2 $star, $star, sub { print "ok $i\n" star2($star, $star, sub { print "ok $i\n" if $_[0] eq 'FOO' and $_[1] eq 'FOO' }); $i++; star2 *FOO, *BAR, sub { print "ok $i\n" - if $_[0] eq \*FOO and $_[0] eq \*BAR }; $i++; + if $_[0] eq \*FOO and $_[1] eq \*BAR }; $i++; star2(*FOO, *BAR, sub { print "ok $i\n" - if $_[0] eq \*FOO and $_[0] eq \*BAR }); $i++; + if $_[0] eq \*FOO and $_[1] eq \*BAR }); $i++; star2 \*FOO, \*BAR, sub { no strict 'refs'; print "ok $i\n" - if $_[0] eq \*{'FOO'} and $_[0] eq \*{'BAR'} }; $i++; + if $_[0] eq \*{'FOO'} and $_[1] eq \*{'BAR'} }; $i++; star2(\*FOO, \*BAR, sub { no strict 'refs'; print "ok $i\n" - if $_[0] eq \*{'FOO'} and $_[0] eq \*{'BAR'} }); $i++; + if $_[0] eq \*{'FOO'} and $_[1] eq \*{'BAR'} }); $i++; +# test scalarref prototype +sub sreftest (\$$) { + print "ok $_[1]\n" if ref $_[0]; +} +{ + no strict 'vars'; + sreftest my $sref, $i++; + sreftest($helem{$i}, $i++); + sreftest $aelem[0], $i++; +}