summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-05 06:13:27 +0000
committerZefram <zefram@fysh.org>2017-12-05 06:21:35 +0000
commit0740a29d60ebd4ff72090340b0140ec2210e90c7 (patch)
treedad4acffe5bffdd0e3b9ddfbb07140218c0bacac /gv.c
parent28ef70489d76deb9024de42a0571162f323148c8 (diff)
downloadperl-0740a29d60ebd4ff72090340b0140ec2210e90c7.tar.gz
stop using &PL_sv_yes as no-op method
Method lookup yields a fake method for ->import or ->unimport if there's no actual method, for historical reasons so that "use" doesn't barf if there's no import method. This fake method used to be &PL_sv_yes being used as a magic placeholder, recognised specially by pp_entersub. But &PL_sv_yes is a string, which we'd expect to serve as a symbolic CV ref. Change method lookup to yield an actual CV with a body in this case, and remove the special case from pp_entersub. This fixes the remaining part of [perl #126042].
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gv.c b/gv.c
index bc5b388588..00adb8995c 100644
--- a/gv.c
+++ b/gv.c
@@ -1091,9 +1091,10 @@ Perl_gv_fetchmethod_pvn_flags(pTHX_ HV *stash, const char *name, const STRLEN le
/* This is the special case that exempts Foo->import and
Foo->unimport from being an error even if there's no
import/unimport subroutine */
- if (strEQ(name,"import") || strEQ(name,"unimport"))
- gv = MUTABLE_GV(&PL_sv_yes);
- else if (autoload)
+ if (strEQ(name,"import") || strEQ(name,"unimport")) {
+ gv = (GV*)sv_2mortal((SV*)newCONSTSUB_flags(NULL,
+ NULL, 0, 0, NULL));
+ } else if (autoload)
gv = gv_autoload_pvn(
ostash, name, name_end - name, GV_AUTOLOAD_ISMETHOD|flags
);