diff options
-rw-r--r-- | gv.c | 6 | ||||
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | sv.c | 2 | ||||
-rw-r--r-- | t/op/coresubs.t | 6 |
4 files changed, 11 insertions, 5 deletions
@@ -1050,7 +1050,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, const I32 no_init = flags & (GV_NOADD_NOINIT | GV_NOINIT); const I32 no_expand = flags & GV_NOEXPAND; const I32 add = flags & ~GV_NOADD_MASK; - const bool addmg = !!(flags & GV_ADDMG); + bool addmg = !!(flags & GV_ADDMG); const char *const name_end = nambeg + full_len; const char *const name_em1 = name_end - 1; U32 faking_it; @@ -1402,6 +1402,10 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, new ATTRSUB. */ (void)core_prototype((SV *)cv, name, code, &opnum); if (ampable) { + if (addmg) { + hv_store(stash,name,len,(SV *)gv,0); + addmg = FALSE; + } CvLVALUE_on(cv); newATTRSUB(oldsavestack_ix, newSVOP( @@ -427,7 +427,7 @@ PP(pp_rv2cv) GV *gv; HV *stash_unused; const I32 flags = (PL_op->op_flags & OPf_SPECIAL) - ? 0 + ? GV_ADDMG : ((PL_op->op_private & (OPpLVAL_INTRO|OPpMAY_RETURN_CONSTANT)) == OPpMAY_RETURN_CONSTANT) ? GV_ADD|GV_NOEXPAND : GV_ADD; @@ -8884,7 +8884,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref) } *st = GvESTASH(gv); fix_gv: - if (lref && !GvCVu(gv)) { + if (lref & ~GV_ADDMG && !GvCVu(gv)) { SV *tmpsv; ENTER; tmpsv = newSV(0); diff --git a/t/op/coresubs.t b/t/op/coresubs.t index e64655339b..f0ebe8ed5b 100644 --- a/t/op/coresubs.t +++ b/t/op/coresubs.t @@ -31,10 +31,12 @@ while(<$kh>) { chomp(my $word = $'); if($& eq '+' || $unsupported{$word}) { $tests ++; - ok !defined &{\&{"CORE::$word"}}, "no CORE::$word"; + ok !defined &{"CORE::$word"}, "no CORE::$word"; } else { - $tests += 3; + $tests += 4; + + ok defined &{"CORE::$word"}, "defined &{'CORE::$word'}"; my $proto = prototype "CORE::$word"; *{"my$word"} = \&{"CORE::$word"}; |