diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-09-30 18:27:58 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-30 20:16:31 -0700 |
commit | f0e9f182fe3d00c8f9a8a6697fbd198f07fcc242 (patch) | |
tree | e1f225f58885de9a2eccdcb3d080fc12b46a3911 /gv.c | |
parent | 2e3468793982c433c4b3838a57fb434ecca63875 (diff) | |
download | perl-f0e9f182fe3d00c8f9a8a6697fbd198f07fcc242.tar.gz |
Restore the package name to overload errors; fix crash
Commit bfcb351493b (which was backported to 5.8.8) caused these error
messages always to mention the overload package, instead of the pack-
age involved:
Can't resolve method "foo" overloading "+" in package "baz"
Stub found while resolving method "foo" overloading "+" in package "baz"
This commit fixes that. A compiler warning alerted me to the possi-
bility of HvNAME being null, so I wrote a small test for that, found
that it crashed, and incorporated the fix for the crash into the same
commit (since it’s the same line of code).
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -2056,9 +2056,10 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing) gv = Perl_gv_fetchmeth(aTHX_ stash, cooky, l, -1); cv = 0; if (gv && (cv = GvCV(gv))) { - const char *hvname; - if (GvNAMELEN(CvGV(cv)) == 3 && strEQ(GvNAME(CvGV(cv)), "nil") - && strEQ(hvname = HvNAME_get(GvSTASH(CvGV(cv))), "overload")) { + 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 + && strEQ(hvname, "overload")) { /* This is a hack to support autoloading..., while knowing *which* methods were declared as overloaded. */ /* GvSV contains the name of the method. */ @@ -2067,7 +2068,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing) DEBUG_o( Perl_deb(aTHX_ "Resolving method \"%"SVf256\ "\" for overloaded \"%s\" in package \"%.256s\"\n", - (void*)GvSV(gv), cp, hvname) ); + (void*)GvSV(gv), cp, HvNAME(stash)) ); if (!gvsv || !SvPOK(gvsv) || !(ngv = gv_fetchmethod_autoload(stash, SvPVX_const(gvsv), FALSE))) @@ -2082,10 +2083,11 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing) "in package \"%.256s\"", (GvCVGEN(gv) ? "Stub found while resolving" : "Can't resolve"), - name, cp, hvname); + name, cp, HvNAME(stash)); } } cv = GvCV(gv = ngv); + } } DEBUG_o( Perl_deb(aTHX_ "Overloading \"%s\" in package \"%.256s\" via \"%.256s::%.256s\"\n", cp, HvNAME_get(stash), HvNAME_get(GvSTASH(CvGV(cv))), |