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. */
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)))
"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))),
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 4982;
+plan tests => 4983;
use Scalar::Util qw(tainted);
use overload '+' => 'justice';
eval {bless[]};
::like $@, qr/^Can't resolve method "justice" overloading "\+" in p(?x:
- )ackage "overload" at /,
+ )ackage "Justus" at /,
'Error message when explicitly named overload method does not exist';
package JustUs;
"JustUs"->${\"(+"};
eval {bless []};
::like $@, qr/^Stub found while resolving method "\?{3}" overloadin(?x:
- )g "\+" in package "overload" at /,
+ )g "\+" in package "JustUs" at /,
'Error message when sub stub is encountered';
}
+{ # undefining the overload stash -- KEEP THIS TEST LAST
+ package ant;
+ use overload '+' => 'onion';
+ $_ = \&overload::nil;
+ undef %overload::;
+ ::ok(1, 'no crash when undefining %overload::');
+}
+
# EOF