In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/120921acd4cf27bb932a725a8cf5c957652b22eb?hp=3a0fe090c1f24f4a3748d00616b87eb4c8dd4475>

- Log -----------------------------------------------------------------
commit 120921acd4cf27bb932a725a8cf5c957652b22eb
Author: Zefram <[email protected]>
Date:   Sun Jan 22 07:26:34 2017 +0000

    fix special-case recreation of *::
    
    If *:: is called for then as a special case it is looked up as
    $::{"main::"}.  If $::{"main::"} has been deleted, then that hash entry
    is recreated.  But formerly it was only recreated as an undef scalar,
    which broke things relying on glob lookup returning a glob.  Now in
    that special case the recreated hash entry is initialised as a glob,
    and populated with the customary recursive reference to the main stash.
    Fixes [perl #129869].
-----------------------------------------------------------------------

Summary of changes:
 gv.c         | 11 +++++++++--
 t/op/stash.t |  9 ++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gv.c b/gv.c
index fff8e95c75..ae800c923b 100644
--- a/gv.c
+++ b/gv.c
@@ -1663,8 +1663,15 @@ S_parse_gv_stash_name(pTHX_ HV **stash, GV **gv, const 
char **name,
                 name_cursor++;
             *name = name_cursor+1;
             if (*name == name_end) {
-                if (!*gv)
-                    *gv = MUTABLE_GV(*hv_fetchs(PL_defstash, "main::", TRUE));
+                if (!*gv) {
+                   *gv = MUTABLE_GV(*hv_fetchs(PL_defstash, "main::", TRUE));
+                   if (SvTYPE(*gv) != SVt_PVGV) {
+                       gv_init_pvn(*gv, PL_defstash, "main::", 6,
+                                   GV_ADDMULTI);
+                       GvHV(*gv) =
+                           MUTABLE_HV(SvREFCNT_inc_simple(PL_defstash));
+                   }
+               }
                 return TRUE;
             }
         }
diff --git a/t/op/stash.t b/t/op/stash.t
index 8d2d628bdd..c9634a370a 100644
--- a/t/op/stash.t
+++ b/t/op/stash.t
@@ -6,7 +6,7 @@ BEGIN {
     set_up_inc( qw(../lib) );
 }
 
-plan( tests => 54 );
+plan( tests => 55 );
 
 # Used to segfault (bug #15479)
 fresh_perl_like(
@@ -349,3 +349,10 @@ is runperl(
    ),
    "ok\n",
    "[perl #128238] non-stashes in stashes";
+
+is runperl(
+    prog => '%:: = (); print *{q|::|}, qq|\n|',
+    stderr => 1,
+   ),
+   "*main::main::\n",
+   "[perl #129869] lookup %:: by name after clearing %::";

--
Perl5 Master Repository

Reply via email to