From: Simon Cozens Date: Wed, 27 Dec 2000 02:30:03 +0000 (+0000) Subject: lvalue AUTOLOAD. No, really. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d32f2495b04e916e41d6514e2a6126c7223b49c9;p=p5sagit%2Fp5-mst-13.2.git lvalue AUTOLOAD. No, really. Message-ID: <20001227023003.A7677@deep-dark-truthful-mirror.perlhacker.org> p4raw-id: //depot/perl@8243 --- diff --git a/pp.c b/pp.c index 2cb463e..8914104 100644 --- a/pp.c +++ b/pp.c @@ -385,8 +385,12 @@ PP(pp_rv2cv) if (cv) { if (CvCLONE(cv)) cv = (CV*)sv_2mortal((SV*)cv_clone(cv)); - if ((PL_op->op_private & OPpLVAL_INTRO) && !CvLVALUE(cv)) - DIE(aTHX_ "Can't modify non-lvalue subroutine call"); + if ((PL_op->op_private & OPpLVAL_INTRO)) { + if (gv && GvCV(gv) == cv && (gv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), FALSE))) + cv = GvCV(gv); + if (!CvLVALUE(cv)) + DIE(aTHX_ "Can't modify non-lvalue subroutine call"); + } } else cv = (CV*)&PL_sv_undef; diff --git a/t/pragma/sub_lval.t b/t/pragma/sub_lval.t index 660e72d..1b8b73a 100755 --- a/t/pragma/sub_lval.t +++ b/t/pragma/sub_lval.t @@ -1,4 +1,4 @@ -print "1..46\n"; +print "1..47\n"; BEGIN { chdir 't' if -d 't'; @@ -427,3 +427,12 @@ $a = \&lv1nn; $a->() = 8; print "# '$nnewvar'.\nnot " unless $nnewvar eq '8'; print "ok 46\n"; + +# This must happen at run time +eval { + sub AUTOLOAD : lvalue { $newvar }; +}; +foobar() = 12; +print "# '$newvar'.\nnot " unless $newvar eq "12"; +print "ok 47\n"; +