diff options
author | David Mitchell <davem@iabyn.com> | 2018-11-05 12:29:27 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2018-11-05 12:29:27 +0000 |
commit | b97fe865adca6799771c93fc17e9f36ae7272e72 (patch) | |
tree | af325b560ea90f9b6f8bb927a4b823fc08d7408e /pp.c | |
parent | 328d9079796a9f9f8dfb4813f36e50e8a77a0748 (diff) | |
download | perl-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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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); } |