summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-28 22:17:27 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:57:29 -0700
commitac0da85a81db901d9fb68053bd74f44aac344c80 (patch)
treeb622e8cfc5a8739c5b9a861597c14459117405d9 /pp.c
parent30494daf6820aa3857d002f5d78c5d5a9feb15a5 (diff)
downloadperl-ac0da85a81db901d9fb68053bd74f44aac344c80.tar.gz
Assignment to \local @array and \local %hash
Doesn’t work with lhs parentheses yet.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index a96d10985f..e2ea31a1f2 100644
--- a/pp.c
+++ b/pp.c
@@ -6197,8 +6197,9 @@ PP(pp_refassign)
SV * const left = PL_op->op_flags & OPf_STACKED ? POPs : NULL;
dTOPss;
const char *bad = NULL;
+ const U8 type = PL_op->op_private & OPpLVREF_TYPE;
if (!SvROK(sv)) DIE(aTHX_ "Assigned value is not a reference");
- switch (PL_op->op_private & OPpLVREF_TYPE) {
+ switch (type) {
case OPpLVREF_SV:
if (SvTYPE(SvRV(sv)) > SVt_PVLV)
bad = " SCALAR";
@@ -6232,9 +6233,21 @@ PP(pp_refassign)
}
case SVt_PVGV:
if (PL_op->op_private & OPpLVAL_INTRO) {
- save_pushptrptr((GV *)left, SvREFCNT_inc_simple(GvSV(left)),
- SAVEt_GVSV);
- GvSV(left) = 0;
+ if (type == OPpLVREF_SV) {
+ save_pushptrptr((GV *)left,
+ SvREFCNT_inc_simple(GvSV(left)),
+ SAVEt_GVSV);
+ GvSV(left) = 0;
+ }
+ else if (type == OPpLVREF_AV)
+ /* XXX Inefficient, as it creates a new AV, which we are
+ about to clobber. */
+ save_ary((GV *)left);
+ else {
+ assert(type == OPpLVREF_HV);
+ /* XXX Likewise inefficient. */
+ save_hash((GV *)left);
+ }
}
gv_setref(left, sv);
SvSETMAGIC(left);