summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-06-23 12:06:11 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-06-23 12:06:11 -0700
commitbdbfc51a7bc15a2f0a187c1ef09a16838a4c9915 (patch)
treed19609ab2341d791281ead3df2f3e72d8d04d84b
parent7b3b090481956031f1fcd4f2190cb437c9bbe815 (diff)
downloadperl-bdbfc51a7bc15a2f0a187c1ef09a16838a4c9915.tar.gz
Stop undef &foo from crashing on lex subs
-rw-r--r--pp.c7
-rw-r--r--t/op/lexsub.t10
2 files changed, 15 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 77a9f01653..f8a31e2cae 100644
--- a/pp.c
+++ b/pp.c
@@ -973,7 +973,12 @@ PP(pp_undef)
"Constant subroutine %"SVf" undefined",
SVfARG(CvANON((const CV *)sv)
? newSVpvs_flags("(anonymous)", SVs_TEMP)
- : sv_2mortal(newSVhek(GvENAME_HEK(CvGV((const CV *)sv))))));
+ : sv_2mortal(newSVhek(
+ CvNAMED(sv)
+ ? CvNAME_HEK((CV *)sv)
+ : GvENAME_HEK(CvGV((const CV *)sv))
+ ))
+ ));
/* FALLTHROUGH */
case SVt_PVFM:
{
diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index 27b6de7326..0141399020 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -8,7 +8,7 @@ BEGIN {
*bar::like = *like;
}
no warnings 'deprecated';
-plan 135;
+plan 136;
# -------------------- Errors with feature disabled -------------------- #
@@ -703,3 +703,11 @@ like runperl(
),
qr/Deep recursion on subroutine "foo"/,
'deep recursion warnings for lexical subs do not crash';
+
+like runperl(
+ switches => [ '-Mfeature=:all', '-Mwarnings=FATAL,all', '-M-warnings=experimental::lexical_subs' ],
+ prog => 'my sub foo() { 42 } undef &foo',
+ stderr => 1
+ ),
+ qr/Constant subroutine foo undefined at /,
+ 'constant undefinition warnings for lexical subs do not crash';