if (!outpad || !(sv = outpad[PARENT_PAD_INDEX(namesv)])
|| ( SvPADSTALE(sv) && !SvPAD_STATE(namesv)
&& (!outside || !CvDEPTH(outside))) ) {
+ /* diag_listed_as: Variable "%s" is not available */
Perl_ck_warner(aTHX_ packWARN(WARN_CLOSURE),
- "Variable \"%"SVf"\" is not available", namesv);
+ "%se \"%"SVf"\" is not available",
+ SvPVX_const(namesv)[0] == '&'
+ ? "Subroutin"
+ : "Variabl",
+ namesv);
sv = NULL;
}
else
else if (PadnameLEN(namesv)>1 && !PadnameIsOUR(namesv))
{
/* my sub */
+ sv = newSV_type(SVt_PVCV);
+ if (SvTYPE(ppad[ix]) == SVt_PVCV) {
/* This is actually a stub with a proto CV attached
to it by magic. Since the stub itself is used
when the proto is cloned, we need a new stub
assert(mg->mg_obj);
assert(SvTYPE(ppad[ix]) == SVt_PVCV);
assert(CvNAME_HEK((CV *)ppad[ix]));
- sv = newSV_type(SVt_PVCV);
CvNAME_HEK_set(sv,
share_hek_hek(CvNAME_HEK((CV *)ppad[ix])));
sv_magic(sv,mg->mg_obj,PERL_MAGIC_proto,NULL,0);
+ }
+ else {
+ assert(SvTYPE(ppad[ix]) == SVt_NULL);
+ /* Unavailable; just provide a stub, but name it */
+ CvNAME_HEK_set(
+ sv,
+ share_hek(SvPVX_const(namesv)+1,
+ SvCUR(namesv) - 1
+ * (SvUTF8(namesv) ? -1 : 1),
+ 0)
+ );
+ }
}
else sv = SvREFCNT_inc(ppad[ix]);
else if (sigil == '@')
*bar::like = *like;
}
no warnings 'deprecated';
-plan 115;
+plan 117;
# -------------------- our -------------------- #
->()();
is $w, "Subroutine \"&x\" is not available at khaki line 90.\n",
"unavailability warning during compilation of named sub in anon";
+
+ undef $w;
+ sub not_lexical9 {
+ my sub x {};
+ format =
+@
+&x
+.
+ }
+ eval { write };
+ my($f,$l) = (__FILE__,__LINE__ - 1);
+ is $w, "Subroutine \"&x\" is not available at $f line $l.\n",
+ 'unavailability warning during cloning';
+ $l -= 3;
+ is $@, "Undefined subroutine &x called at $f line $l.\n",
+ 'Vivified sub is correctly named';
}
# -------------------- Interactions (and misc tests) -------------------- #