summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c2
-rw-r--r--t/op/lexsub.t12
2 files changed, 12 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 7e3058dadd..e4d6acab42 100644
--- a/gv.c
+++ b/gv.c
@@ -2553,7 +2553,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
numifying instead of C's "+0". */
gv = Perl_gv_fetchmeth_pvn(aTHX_ stash, cooky, l, -1, 0);
cv = 0;
- if (gv && (cv = GvCV(gv))) {
+ if (gv && (cv = GvCV(gv)) && CvGV(cv)) {
if(GvNAMELEN(CvGV(cv)) == 3 && strEQ(GvNAME(CvGV(cv)), "nil")){
const char * const hvname = HvNAME_get(GvSTASH(CvGV(cv)));
if (hvname && HEK_LEN(HvNAME_HEK(GvSTASH(CvGV(cv)))) == 8
diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index 54bb985f7d..774357b6f4 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -7,7 +7,7 @@ BEGIN {
*bar::is = *is;
*bar::like = *like;
}
-plan 122;
+plan 124;
# -------------------- Errors with feature disabled -------------------- #
@@ -322,6 +322,11 @@ like runperl(
A::bar();
is $stuff, 'A::bar', 'state sub assigned to *AUTOLOAD can autoload';
}
+{
+ state sub quire{qr "quires"}
+ package o { use overload qr => \&quire }
+ ok "quires" =~ bless([], o::), 'state sub used as overload method';
+}
# -------------------- my -------------------- #
@@ -624,6 +629,11 @@ like runperl(
A::bar();
is $stuff, 'A::bar', 'my sub assigned to *AUTOLOAD can autoload';
}
+{
+ my sub quire{qr "quires"}
+ package mo { use overload qr => \&quire }
+ ok "quires" =~ bless([], mo::), 'my sub used as overload method';
+}
# -------------------- Interactions (and misc tests) -------------------- #