diff options
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | op.c | 10 | ||||
-rwxr-xr-x | t/op/runlevel.t | 4 | ||||
-rw-r--r-- | toke.c | 6 |
4 files changed, 14 insertions, 8 deletions
@@ -662,7 +662,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) strEQ(name, "ARGVOUT"))) global = TRUE; } - else if (*name == '_' && (!name[1] || strEQ(name,"__ANON__"))) + else if (*name == '_' && !name[1]) global = TRUE; if (global) @@ -4755,13 +4755,15 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) name = o ? SvPVx(cSVOPo->op_sv, n_a) : Nullch; if (!name && PERLDB_NAMEANON && CopLINE(PL_curcop)) { SV *sv = sv_newmortal(); - Perl_sv_setpvf(aTHX_ sv, "__ANON__[%s:%"IVdf"]", + Perl_sv_setpvf(aTHX_ sv, "%s[%s:%"IVdf"]", + PL_curstash ? "__ANON__" : "__ANON__::__ANON__", CopFILE(PL_curcop), (IV)CopLINE(PL_curcop)); aname = SvPVX(sv); } else aname = Nullch; - gv = gv_fetchpv(name ? name : (aname ? aname : "__ANON__"), + gv = gv_fetchpv(name ? name : (aname ? aname : + (PL_curstash ? "__ANON__" : "__ANON__::__ANON__")), GV_ADDMULTI | ((block || attrs) ? 0 : GV_NOINIT), SVt_PVCV); @@ -5179,7 +5181,9 @@ Used by C<xsubpp> to hook up XSUBs as Perl subs. CV * Perl_newXS(pTHX_ char *name, XSUBADDR_t subaddr, char *filename) { - GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV); + GV *gv = gv_fetchpv(name ? name : + (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"), + GV_ADDMULTI, SVt_PVCV); register CV *cv; if ((cv = (name ? GvCV(gv) : Nullcv))) { diff --git a/t/op/runlevel.t b/t/op/runlevel.t index 6a10e8b4ab..1eedda8b09 100755 --- a/t/op/runlevel.t +++ b/t/op/runlevel.t @@ -311,7 +311,7 @@ $SIG{__DIE__} = sub { eval { die }; &{sub { eval 'die' }}(); sub foo { eval { die } } foo(); -{package rmb; sub{ eval{die} } ->() }; # check __ANON__ is global +{package rmb; sub{ eval{die} } ->() }; # check __ANON__ knows package EXPECT In DIE main|-|8|(eval) @@ -323,7 +323,7 @@ main|-|10|(eval) main|-|10|main::foo In DIE rmb|-|11|(eval) -rmb|-|11|main::__ANON__ +rmb|-|11|rmb::__ANON__ ######## package TEST; @@ -4027,7 +4027,8 @@ Perl_yylex(pTHX) if (strEQ(proto, "$")) OPERATOR(UNIOPSUB); if (*proto == '&' && *s == '{') { - sv_setpv(PL_subname,"__ANON__"); + sv_setpv(PL_subname, PL_curstash ? + "__ANON__" : "__ANON__::__ANON__"); PREBLOCK(LSTOPSUB); } } @@ -5008,7 +5009,8 @@ Perl_yylex(pTHX) force_next(THING); } if (!have_name) { - sv_setpv(PL_subname,"__ANON__"); + sv_setpv(PL_subname, + PL_curstash ? "__ANON__" : "__ANON__::__ANON__"); TOKEN(ANONSUB); } (void) force_word(PL_oldbufptr + tboffset, WORD, |