summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-11-05 12:29:27 +0000
committerDavid Mitchell <davem@iabyn.com>2018-11-05 12:29:27 +0000
commitb97fe865adca6799771c93fc17e9f36ae7272e72 (patch)
treeaf325b560ea90f9b6f8bb927a4b823fc08d7408e /pp.c
parent328d9079796a9f9f8dfb4813f36e50e8a77a0748 (diff)
downloadperl-b97fe865adca6799771c93fc17e9f36ae7272e72.tar.gz
Don't localise array / hash slice ref assignment
RT #133538 The experimental ref assignment aliasing feature, when applied to array or hash slices, was treating the slice as if it was always localized; e.g. \(@a[3,5,7]) = \(....); was being interpreted as local \(@a[3,5,7]) = \(....); The fix is simple: check for the OPpLVAL_INTRO flag actually being set on the op, rather than unconditionally localising the array/hash elements.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index cfa343fbbb..6d432acd31 100644
--- a/pp.c
+++ b/pp.c
@@ -6599,10 +6599,12 @@ PP(pp_lvrefslice)
while (++MARK <= SP) {
SV * const elemsv = *MARK;
- if (SvTYPE(av) == SVt_PVAV)
- S_localise_aelem_lval(aTHX_ av, elemsv, can_preserve);
- else
- S_localise_helem_lval(aTHX_ (HV *)av, elemsv, can_preserve);
+ if (UNLIKELY(localizing)) {
+ if (SvTYPE(av) == SVt_PVAV)
+ S_localise_aelem_lval(aTHX_ av, elemsv, can_preserve);
+ else
+ S_localise_helem_lval(aTHX_ (HV *)av, elemsv, can_preserve);
+ }
*MARK = sv_2mortal(newSV_type(SVt_PVMG));
sv_magic(*MARK,(SV *)av,PERL_MAGIC_lvref,(char *)elemsv,HEf_SVKEY);
}