From: Rick Delaney Date: Sat, 18 Mar 2006 19:52:11 +0000 (-0500) Subject: Re: [perl #38710] localised stash slice X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7a2e501a470d7096f8a5847c8002615db94d259b;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #38710] localised stash slice Message-ID: <20060319005211.GM25733@localhost.localdomain> One can now localize slices. p4raw-id: //depot/perl@27547 --- diff --git a/pp.c b/pp.c index 7a93883..383b426 100644 --- a/pp.c +++ b/pp.c @@ -3844,13 +3844,17 @@ PP(pp_hslice) DIE(aTHX_ PL_no_helem_sv, keysv); } if (localizing) { - if (preeminent) - save_helem(hv, keysv, svp); - else { - STRLEN keylen; - const char *key = SvPV_const(keysv, keylen); - SAVEDELETE(hv, savepvn(key,keylen), keylen); - } + if (HvNAME_get(hv) && isGV(*svp)) + save_gp((GV*)*svp, !(PL_op->op_flags & OPf_SPECIAL)); + else { + if (preeminent) + save_helem(hv, keysv, svp); + else { + STRLEN keylen; + const char *key = SvPV_const(keysv, keylen); + SAVEDELETE(hv, savepvn(key,keylen), keylen); + } + } } } *MARK = svp ? *svp : &PL_sv_undef; diff --git a/t/op/local.t b/t/op/local.t index daa36a7..561e395 100755 --- a/t/op/local.t +++ b/t/op/local.t @@ -362,10 +362,8 @@ sub f { ok(0 == $[); } ::ok(f1() eq "f1", "localised sub restored"); { local @Other::{qw/ f1 f2 /} = (sub { "j1" }, sub { "j2" }); - local $::TODO = "localisation of stash slice not working"; ::ok(f1() eq "j1", "localised sub via stash slice"); ::ok(f2() eq "j2", "localised sub via stash slice"); - undef $::TODO; } ::ok(f1() eq "f1", "localised sub restored"); ::ok(f2() eq "f2", "localised sub restored");