diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-06-23 12:06:11 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-07-27 23:16:14 -0700 |
commit | 510f162848ed052ce0d7d3556ab6a9076b1ca8ae (patch) | |
tree | 924f97c8bef983953053abeed37a81737549ca54 | |
parent | c67a57e45fb9e35ae90420dec38715c471c52a3f (diff) | |
download | perl-510f162848ed052ce0d7d3556ab6a9076b1ca8ae.tar.gz |
Stop undef &foo from crashing on lex subs
(cherry picked from commit bdbfc51a7bc15a2f0a187c1ef09a16838a4c9915)
-rw-r--r-- | pp.c | 7 | ||||
-rw-r--r-- | t/op/lexsub.t | 10 |
2 files changed, 15 insertions, 2 deletions
@@ -969,7 +969,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'; |