From f1f99dc1f9e949ceafeeaead7b5f43b1aab8224d Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 18 Nov 2011 16:17:22 -0800 Subject: [PATCH] Copy magic during localisation even for GVs The magic-copying is skipped for GVs. This logic goes back to perl 5.000 (patch a0d0e21e). I think it has always been wrong. --- scope.c | 2 +- t/op/tie.t | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scope.c b/scope.c index f14be1e..cb0e8c5 100644 --- a/scope.c +++ b/scope.c @@ -181,7 +181,7 @@ S_save_scalar_at(pTHX_ SV **sptr, const U32 flags) osv = *sptr; sv = (flags & SAVEf_KEEPOLDELEM) ? osv : (*sptr = newSV(0)); - if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) { + if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv)) { if (SvGMAGICAL(osv)) { SvFLAGS(osv) |= (SvFLAGS(osv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; diff --git a/t/op/tie.t b/t/op/tie.t index 2431271..b6567fc 100644 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -1164,3 +1164,19 @@ HASH HASH ARRAY ARRAY +######## + +# Localising a tied variable with a typeglob in it should copy magic +sub TIESCALAR{bless[]} +sub FETCH{warn "fetching\n"; *foo} +sub STORE{} +tie $x, ""; +local $x; +warn "before"; +"$x"; +warn "after"; +EXPECT +fetching +before at - line 8. +fetching +after at - line 10. -- 2.7.4