Re: [perl #38710] localised stash slice
Rick Delaney [Sat, 18 Mar 2006 19:52:11 +0000 (14:52 -0500)]
Message-ID: <20060319005211.GM25733@localhost.localdomain>

One can now localize slices.

p4raw-id: //depot/perl@27547

pp.c
t/op/local.t

diff --git a/pp.c b/pp.c
index 7a93883..383b426 100644 (file)
--- 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;
index daa36a7..561e395 100755 (executable)
@@ -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");