summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c2
-rwxr-xr-xt/op/anonsub.t5
-rwxr-xr-xt/op/runlevel.t4
3 files changed, 10 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 653837770e..2ed4809409 100644
--- a/gv.c
+++ b/gv.c
@@ -656,7 +656,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
strEQ(name, "ARGVOUT")))
global = TRUE;
}
- else if (*name == '_' && !name[1])
+ else if (*name == '_' && (!name[1] || strEQ(name,"__ANON__")))
global = TRUE;
if (global)
diff --git a/t/op/anonsub.t b/t/op/anonsub.t
index 0e4c40494f..fef40f935a 100755
--- a/t/op/anonsub.t
+++ b/t/op/anonsub.t
@@ -97,3 +97,8 @@ sub X {
X();
EXPECT
ok 1
+########
+package;
+print sub { return "ok 1\n" } -> ();
+EXPECT
+ok 1
diff --git a/t/op/runlevel.t b/t/op/runlevel.t
index 60c19a5e4c..03e253e6e6 100755
--- a/t/op/runlevel.t
+++ b/t/op/runlevel.t
@@ -311,6 +311,7 @@ $SIG{__DIE__} = sub {
eval { die };
&{sub { eval 'die' }}();
sub foo { eval { die } } foo();
+{package rmb; sub{ eval{die} } ->() }; # check __ANON__ is global
EXPECT
In DIE
main|-|8|(eval)
@@ -320,6 +321,9 @@ main|-|9|main::__ANON__
In DIE
main|-|10|(eval)
main|-|10|main::foo
+In DIE
+rmb|-|11|(eval)
+rmb|-|11|main::__ANON__
########
package TEST;