From: Mark-Jason Dominus Date: Mon, 24 Dec 2001 18:14:48 +0000 (-0500) Subject: PATCH: Restore "Can't declare scalar dereference in my" error X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b6512f489e761186d508cf0b8b7705805cfefc52;hp=ecf68df6e17568faac489c8f52d98e01e32472af;p=p5sagit%2Fp5-mst-13.2.git PATCH: Restore "Can't declare scalar dereference in my" error Message-ID: <20011224231448.25826.qmail@plover.com> p4raw-id: //depot/perl@13881 --- diff --git a/op.c b/op.c index c733052..efb99e0 100644 --- a/op.c +++ b/op.c @@ -2043,6 +2043,9 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) } else if (type == OP_RV2SV || /* "our" declaration */ type == OP_RV2AV || type == OP_RV2HV) { /* XXX does this let anything illegal in? */ + if (cUNOPo->op_first->op_type != OP_GV) { /* MJD 20011224 */ + yyerror(form("Can't declare %s in my", OP_DESC(o))); + } if (attrs) { GV *gv = cGVOPx_gv(cUNOPo->op_first); PL_in_my = FALSE; diff --git a/t/op/eval.t b/t/op/eval.t index 42a71e2..17b8d9d 100755 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -1,6 +1,6 @@ #!./perl -print "1..41\n"; +print "1..45\n"; eval 'print "ok 1\n";'; @@ -221,3 +221,16 @@ print $@; }; print "not ok 41\n" if $@; } + +# Make sure that "my $$x" is forbidden +# 20011224 MJD +{ + eval q{my $$x}; + print $@ ? "ok 42\n" : "not ok 42\n"; + eval q{my @$x}; + print $@ ? "ok 43\n" : "not ok 43\n"; + eval q{my %$x}; + print $@ ? "ok 44\n" : "not ok 44\n"; + eval q{my $$$x}; + print $@ ? "ok 45\n" : "not ok 45\n"; +}