if (AvREAL(arg)) {
I32 index;
for (index=0; index<items; index++)
- SvREFCNT_inc_void(sv_2mortal(SP[-index]));
+ if (SP[-index])
+ SvREFCNT_inc_void_NN(sv_2mortal(SP[-index]));
+ else {
+ SV * const lv =
+ sv_2mortal(newSV_type(SVt_PVLV));
+ SP[-index] = lv;
+ LvTYPE(lv) = 'y';
+ sv_magic(lv,NULL,PERL_MAGIC_defelem,NULL,0);
+ LvTARG(lv) = SvREFCNT_inc_simple_NN(arg);
+ LvSTARGOFF(lv) = AvFILLp(arg) - index;
+ LvTARGLEN(lv) = 1;
+ }
}
SvREFCNT_dec(arg);
if (CxTYPE(cx) == CXt_SUB && CxHASARGS(cx)) {
const I32 items = AvFILLp(av) + 1; /* @_ is not tieable */
if (items) {
+ SSize_t i = 0;
/* Mark is at the end of the stack. */
EXTEND(SP, items);
- Copy(AvARRAY(av), SP + 1, items, SV*);
+ for (; i < items; ++i)
+ if (AvARRAY(av)[i]) SP[i+1] = AvARRAY(av)[i];
+ else {
+ SV * const lv = sv_2mortal(newSV_type(SVt_PVLV));
+ SP[i+1] = lv;
+ LvTYPE(lv) = 'y';
+ sv_magic(lv, NULL, PERL_MAGIC_defelem, NULL, 0);
+ LvTARG(lv) = SvREFCNT_inc_simple_NN(av);
+ LvSTARGOFF(lv) = i;
+ LvTARGLEN(lv) = 1;
+ }
SP += items;
PUTBACK ;
}
use warnings;
use strict;
-plan tests => 89;
+plan tests => 91;
our $TODO;
my $deprecated = 0;
sub { *__ = \@_; goto &null } -> ("rough and tubbery");
is ${*__}[0], 'rough and tubbery', 'goto &foo leaves reified @_ alone';
+# goto &xsub when @_ has nonexistent elements
+{
+ no warnings "uninitialized";
+ local @_ = ();
+ $#_++;
+ & {sub { goto &utf8::encode }};
+ is @_, 1, 'num of elems in @_ after goto &xsub with nonexistent $_[0]';
+ is $_[0], "", 'content of nonexistent $_[0] is modified by goto &xsub';
+}
# [perl #36521] goto &foo in warn handler could defeat recursion avoider
require './test.pl';
}
-plan( tests => 27 );
+plan( tests => 29 );
sub empty_sub {}
is $w, undef,
'*keyword = sub():method{$y} does not cause ambiguity warnings';
}
+
+# &xsub when @_ has nonexistent elements
+{
+ no warnings "uninitialized";
+ local @_ = ();
+ $#_++;
+ &utf8::encode;
+ is @_, 1, 'num of elems in @_ after &xsub with nonexistent $_[0]';
+ is $_[0], "", 'content of nonexistent $_[0] is modified by &xsub';
+}