stash = CopSTASH(PL_curcop);
}
else {
- cv = sv_2cv(*++MARK, &stash, &gv, 0);
+ GV *autogv = NULL;
+ cv = sv_2cv(*++MARK, &stash, &gv, GV_ADD);
+ check_cv:
if (cv && SvPOK(cv)) {
const char * const proto = SvPV_nolen_const(MUTABLE_SV(cv));
if (proto && strEQ(proto, "$$")) {
is_xsub = 1;
}
else if (gv) {
+ goto autoload;
+ }
+ else if (!CvANON(cv) && (gv = CvGV(cv))) {
+ if (cv != GvCV(gv)) cv = GvCV(gv);
+ autoload:
+ if (!autogv && (
+ autogv = gv_autoload_pvn(
+ GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
+ GvNAMEUTF8(gv) ? SVf_UTF8 : 0
+ )
+ )) {
+ cv = GvCVu(autogv);
+ goto check_cv;
+ }
+ else {
SV *tmpstr = sv_newmortal();
gv_efullname3(tmpstr, gv, NULL);
DIE(aTHX_ "Undefined sort subroutine \"%"SVf"\" called",
SVfARG(tmpstr));
+ }
}
else {
DIE(aTHX_ "Undefined subroutine in sort");
require 'test.pl';
}
use warnings;
-plan( tests => 162 );
+plan( tests => 165 );
# these shouldn't hang
{
like $output, qr/^(?:Win)+\z/,
'Match vars do not leak from one $$ sort sub to the next';
}
+
+# [perl #30661] autoloading
+AUTOLOAD { $b <=> $a }
+sub stubbedsub;
+is join("", sort stubbedsub split//, '04381091'), '98431100',
+ 'stubborn AUTOLOAD';
+is join("", sort hopefullynonexistent split//, '04381091'), '98431100',
+ 'AUTOLOAD without stub';
+my $stubref = \&givemeastub;
+is join("", sort $stubref split//, '04381091'), '98431100',
+ 'AUTOLOAD with stubref';